Check for lower cases using islower() function in pandas python

In this Section we will learn how to check for only lower cases using islower() function in pandas dataframe in python.

Let’s see with an example

Create a dataframe

##create dataframe

import pandas as pd
d = {'Quarters' : ['Quarter1','quarter2','quarter3','quarter4'],
     'Revenue':[23400344.567,54363744.678,56789117.456,4132454.987]}
df=pd.DataFrame(d)
print df

The resultant dataframe will be

lower cases in a column of dataframe in python 1

 

Check for lowercase character in column of dataframe in python

# whether only lower case is present in Quarters column of dataframe in Python

df['Quarters_islower'] = map(lambda x: x.islower(), df['Quarters'])
print df

islower() Function in pandas python checks whether the string consists of only lowercase characters.

It returns True when only lowercase characters are present and it returns False when it does not have only lowercase

The result is stored in the Quarters_islower column of the dataframe.

So the resultant dataframe will be

lower cases in a column of dataframe in python 2

 

 

previous lower cases in a column of dataframe in python pandas                                                                                                           next lower cases in a column of dataframe in python pandas

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.