What is the difference between size and count in pandas?

后端 未结 5 1893
误落风尘
误落风尘 2020-11-22 04:37

That is the difference between groupby(\"x\").count and groupby(\"x\").size in pandas ?

Does size just exclude nil ?

5条回答
  •  不知归路
    2020-11-22 05:13

    When we are dealing with normal dataframes then only difference will be an inclusion of NAN values, means count does not include NAN values while counting rows.

    But if we are using these functions with the groupby then, to get the correct results by count() we have to associate any numeric field with the groupby to get the exact number of groups where for size() there is no need for this type of association.

提交回复
热议问题