That is the difference between groupby(\"x\").count
and groupby(\"x\").size
in pandas ?
Does size just exclude nil ?
In addition to all above answers, I would like to point out one more diffrence which I seem significant.
You can correlate Panda's Datarame
size and count with Java's Vectors
size and length. When we create vector some predefined memory is allocated to it. when we reach closer to number of elements it can occupy while adding elements, more memory is allocated to it. Similarly, in DataFrame
as we add elements, memory allocated to it increases.
Size attribute gives number of memory cell allocated to DataFrame
whereas count gives number of elements that are actually present in DataFrame
. For example,
You can see though there are 3 rows in DataFrame
, its size is 6.
This answer covers size and count difference with respect to DataFrame
and not Pandas Series
. I have not checked what happens with Series