Python Pandas Library groupby function

27 June 2023 159 Reading time: 17 second

The groupby function in the Pandas library is used to group data in a DataFrame based on a specific column. This function is useful for performing operations and generating summary statistics on groups within a dataset.


import pandas as pd

# Group data based on the 'category' column
grouped_df = df.groupby('category').sum()
print(grouped_df)

Similar articles