To convert a Python Pandas GroupBy output from Series to DataFrame, we can use count
.
For instance, we write
df1.groupby(["Name", "City"])[['Name','City']].count()
to call groupby
with count
to return the groupby
result as a data frame.
To convert a Python Pandas GroupBy output from Series to DataFrame, we can use count
.
For instance, we write
df1.groupby(["Name", "City"])[['Name','City']].count()
to call groupby
with count
to return the groupby
result as a data frame.