Python Practice › Pandas Programs › Program 70
Capitalise text values
Write a pandas program to capitalise the text values of a column.
Input
["cricket", "Yes", "pass", "FAIL"]
Output
0 Cricket 1 Yes 2 Pass 3 Fail dtype: str
Approach
str.capitalize().
Solution
import pandas as pds = pd.Series(["cricket", "Yes", "pass", "FAIL"])print(s.str.capitalize())Output
0 Cricket 1 Yes 2 Pass 3 Fail dtype: str
Learn the concept
New to this topic? Read the lesson, then come back.