Reputation: 601
Let's say I have a table that has 5 rows and 10 columns:
I would like the function to return me row 2 & 5
Upvotes: 1
Views: 962
Reputation: 26676
Use isna().sum equals to to generate a boolean and then subset
df[df.isna().sum(1).eq(2)]
Upvotes: 0
Reputation: 601
df.isnull().sum(axis=1)
will return the number of missing values per rows.
min(df.isnull().sum(axis=1))
will return the minimum missing values for a row
df[df.isnull().sum(axis=1) == min(df.isnull().sum(axis=1))]
will return the rows that have the minimum amount of missing values
Upvotes: 2