Check for upper cases using isupper() function in pandas python

In this Section we will learn how to check for only upper cases using isupper() function in pandas dataframe in python. Let’s see with an example of isupper() function in pandas.

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

upper cases in a column of dataframe in python 1

 

 

Check for uppercase character in column of dataframe in python

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

df['Quarters_isupper'] = map(lambda x: x.isupper(), df['Quarters'])
print df

isupper() Function in pandas python checks whether the string consists of only uppercase characters.

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

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

So the resultant dataframe will be

upper cases in a column of dataframe in python 2

 

previous upper cases in a column of dataframe in python pandas                                                                                                           next upper 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.