Answers for "if len() dataframe column contain string"

11

dataframe column contains string

df[df['A'].str.contains("hello")]
Posted by: Guest on September-28-2020
0

pandas apply check for string length in column

df=pd.read_csv('filex.csv')
df.A=df.A.apply(lambda x: x if len(x)== 10 else np.nan)
df.B=df.B.apply(lambda x: x if len(x)== 10 else np.nan)
df=df.dropna(subset=['A','B'], how='any')
Posted by: Guest on October-07-2021

Code answers related to "if len() dataframe column contain string"

Python Answers by Framework

Browse Popular Code Answers by Language