Python Practice › Pandas Programs › Program 25
Capitalise first and last letters
Write a pandas program to make the first and last letter of each word uppercase.
Input
["sqatools", "python", "data", "science"]
Output
0 SqatoolS 1 PythoN 2 DatA 3 SciencE dtype: str
Approach
mapa small function.
Solution
import pandas as pds = pd.Series(["sqatools", "python", "data", "science"])print(s.map(lambda w: w[0].upper() + w[1:-1] + w[-1].upper()))Output
0 SqatoolS 1 PythoN 2 DatA 3 SciencE dtype: str
Learn the concept
New to this topic? Read the lesson, then come back.