Delete entire record if column is more than 10 characters how can i delete that entire record.
My dataframe is
Sl.no name reason
1 sara hello
2 ram how are you?
3 raghu how do you do?
4 sai hey !!
Expected Output:
Sl.no name reason
1 sara hello
2 sai hey !!
Thanks inadvance.
I believe need boolean indexing with inverted mask from > to <= and find lengths by Series.str.len:
df = df[df['reason'].str.len() <= 10]
print (df)
Sl.no name reason
0 1 sara hello
3 4 sai hey !!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With