pandas remove cell content if has less than specified number of characters

Here’s another way using np.where:

df['problems'] = np.where(df['problems'].str.len() < 5, '', df['problems'])
print(df)

    name  location           problems
0   Lena     Haifa                   
1  Layla      Aman  not enough points
2   Dili  Istanbul  

             

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top