1

for example:

index1 dog 32 height 
index2 cat 20 height weight 

In this example, the second row has 5 columns so how to find the row which maximum columns(cells)?

Tom Ron
  • 5,906
  • 3
  • 22
  • 38

1 Answers1

0

If df data frame has multiple rows having the same maximum value of not empty columns then use:

df[df.notnull().sum(1)==df.notnull().sum(1).max()]

This selects rows which have number of not empty columns equal to maximum of it across entire data set.

ipj
  • 3,488
  • 1
  • 14
  • 18