lower() function in pandas python – Convert the column to lowercase

In this tutorial we will be using lower() function in pandas to  convert the character column of the python pandas dataframe to lowercase.

  • If the input string in any case (upper, lower or title) , lower() function in pandas converts the string to lower 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

Convert the character column of the python Dataframe to lowercase pandas 1

 

# lower function in python to convert the character column to lowercase 

df['lower_desc'] = map(lambda x: x.lower(), df['Description'])
print df

lower() function in pandas converts any case to the lowercase and stores it in the lower_desc column of the dataframe, so the output will be

Convert the character column of the python Dataframe to lowercase pandas 2

 

lower() function in pandas python - Convert the character column to lowercase                                                                                                           lower() function in pandas python - Convert the character column to lowercase

Author