How can I count number of non-null columns in a row
![Nikhil](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar11.png)
Nikhil
Registered Posts: 1 ✭✭✭
Hi,
How can I count number of non-null columns in a row.
Similar to CountA[D1:D5] in excel.
Thanks in advance
Answers
-
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.