Count number of non-NaN entries in every column of Dataframe

前端 未结 2 1706
长情又很酷
长情又很酷 2020-12-13 23:48

I have a really big DataFrame and I was wondering if there was short (one or two liner) way to get the a count of non-NaN entries in a DataFrame. I don\'t want to do this on

2条回答
  •  情书的邮戳
    2020-12-14 00:12

    The count() method returns the number of non-NaN values in each column:

    >>> df1.count()
    a    3
    b    2
    d    1
    dtype: int64
    

    Similarly, count(axis=1) returns the number of non-NaN values in each row.

提交回复
热议问题