Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #apply #check #string #length #column
ADD COMMENT
Topic
Name
5+7 =