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
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