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)