# importing pandas as pd import pandas as pd # Creating the dataframe df = pd.read_csv("nba.csv") # Print the dataframe df
# applying groupby() function to # group the data on team value. gk = df.groupby('Team') # Let's print the first entries # in all the groups formed. gk.first()
# Finding the values contained in the "Boston Celtics" group gk.get_group('Boston Celtics')
# importing pandas as pd import pandas as pd # Creating the dataframe df = pd.read_csv("nba.csv") # First grouping based on "Team" # Within each team we are grouping based on "Position" gkk = daf.groupby(['Team', 'Position']) # Print the first value in each group gkk.first()
References
https://www.geeksforgeeks.org/python-pandas-dataframe-groupby/