pandas filter length of string

Solutions on MaxInterview for pandas filter length of string by the best coders in the world

showing results for - "pandas filter length of string"
Denis
13 Mar 2017
1import pandas as pd
2
3df = pd.read_csv('filex.csv')
4df['A'] = df['A'].astype('str')
5df['B'] = df['B'].astype('str')
6mask = (df['A'].str.len() == 10) & (df['B'].str.len() == 10)
7df = df.loc[mask]
8print(df)
9