Dataiku Named a Gartner Magic Quadrant Leader 2 Years Running! Read More

How can I count number of non-null columns in a row

Nikhil
Level 1
How can I count number of non-null columns in a row

Hi,

How can I count number of non-null columns in a row.

Similar to CountA[D1:D5] in excel.

 

Thanks in advance

0 Kudos
1 Reply
djoguns
Level 1

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.

0 Kudos
A banner prompting to get Dataiku DSS