In this tutorial we will be using upper() function in pandas, to convert the character column of the python pandas dataframe to uppercase.
- If the input string is in any case (upper, lower or title) , upper() function in pandas converts the string to upper case.
Lets look it with an Example
Create dataframe:
## create dataframe import pandas as pd d = {'Quarters' : ['quarter1','quarter2','quarter3','quarter4'], 'Description' : ['First Quarter of the year', 'second quarter of the year', 'Third Quarter of the year', 'FOURTH QUARTER OF THE YEAR']} df=pd.DataFrame(d) print df
resultant dataframe will be
# upper function in python to convert the character column to uppercase df['upper_desc'] = map(lambda x: x.upper(), df['Description']) print df
upper() function in pandas converts any case to the uppercase and stores it in the upper_desc column of the dataframe, so the output will be