Reputation:
Data frame is below
name,id_number
Tom,ABC1234567
Mak,None
Sim,ABC
None,20110159893
Cases
Name should not None
id_number should not None
id_number should not less than 4 numbers
Expected Out
df['out']
Tom,ABC1234567
How to write a function and apply with one condition
Upvotes: 1
Views: 47
Reputation: 6159
you need,
df = df.replace('None',np.nan)
df[df.notnull().all(axis=1) & (df['id_number'].str.len() > 3) ]
Upvotes: 0
Reputation: 862481
Use boolean indexing
with Series.notna
and Series.str.len
and test by Series.gt
for greater:
df = df[df['name'].notna() & df['id_number'].notna() & df['id_number'].str.len().gt(4)]
print (df)
name id_number
0 Tom ABC1234567
Alternative:
df = df[df[['name','id_number']].notna().all(axis=1) & df['id_number'].str.len().gt(4)]
Upvotes: 2