Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas filter length of string

import pandas as pd

df = pd.read_csv('filex.csv')
df['A'] = df['A'].astype('str')
df['B'] = df['B'].astype('str')
mask = (df['A'].str.len() == 10) & (df['B'].str.len() == 10)
df = df.loc[mask]
print(df)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #filter #length #string
ADD COMMENT
Topic
Name
4+3 =