isalnum() Function in pandas – Check for Alphanumeric in a dataframe in python

isalnum() Function in pandas is used to check for the presence of alphanumeric character in a column of dataframe in python – pandas. Let’s see an example isalnum() 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

alpha numeric of dataframe in python 1

 

Check for alphanumeric in column of dataframe in python

# whether alpha numeric values present in Quarters column of dataframe in Python

df['Quarters_isalphanumeric'] = map(lambda x: x.isalnum(), df['Quarters'])
print df

isalnum() Function in python checks whether the string consists of alphanumeric characters.

It returns True when alphanumeric value is present and it returns False when the alphanumeric value is not present.

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

So the resultant dataframe will be

alpha numeric of dataframe in python

 

previous alpha numeric of dataframe in python isalnum() function in pandas                                                                                                           next alpha numeric of dataframe in python isalnum() function in 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.

    View all posts