Python Practice › Pandas Programs › Program 70

Capitalise text values

EasyPandas Programs · 70 of 95

Write a pandas program to capitalise the text values of a column.

Advertisement
Input
["cricket", "Yes", "pass", "FAIL"]
Output
0    Cricket
1        Yes
2       Pass
3       Fail
dtype: str

Approach

  1. str.capitalize().

Solution

Python
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
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs