The major difference is "size" includes NaN values, the "count" does not include NaN. The below example will help you to understand:
df = pd.Dataframe( {"Name":["Nitin", "Sanju", "Manisha", "Manisha", "Sanju" , "Manisha"],
"City":["Bombay", "Bombay", "Delhi", "Bombay", "Bombay", "Delhi"],
"Val": [1, 2, 2, np.nan, np.nan, 3]})
df output:
# Output:
# City Name Val
# 0 Bombay Nitin 1.0
# 1 Bombay Sanju 2.0
# 2 Delhi Manisha 2.0
# 3 Bombay Manisha NaN
# 4 Bombay Sanju NaN
# 5 Delhi Manisha 3.0
df.groupby(["Name", "City"])['Val'].size().reset_index(name='Size')
# Output:
# Name City Size
# 0 Nitin Bombay 1
# 1 Sanju Bombay 2
# 2 Manisha Delhi 2
# 3 Manisha Delhi 1
df.groupby(["Name", "City"])['Val'].count().reset_index(name='Count')
# Output:
# Name City Size
# 0 Nitin Bombay 1
# 1 Sanju Bombay 1
# 2 Manisha Delhi 2
# 3 Manisha Delhi 0
I hope this example works for you.