Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi,
How can I count number of non-null columns in a row.
Similar to CountA[D1:D5] in excel.
Thanks in advance
Hi Nikhil,
See below:
df as your dataframe.
df.apply(lambda x: x.count(), axis=1)
Or better still assign the count to another variable.
df['non_null_count'] = df.apply(lambda x: x.count(), axis=1)
Cheers.