Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I am trying to remove the rows in the data frame with more than 7 null values. Please suggest something that is efficient to achieve this.

1 Answer

0 votes
by (41.4k points)

The below line of code will keep the rows which have nan's less than 7 in the dataframe, and will remove all the rows having nan's > 7.

df = df[df.isnull().sum(axis=1) < 7]

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...