2

I've got a DataFrame with PLAYER_NAME, the corresponding cluster they're assigned to, their team's net rating, and their team ids. This is what it looks like:

This

I'd like to have a bunch of bar charts for each team that look like the following: this

The would be matched with the team's net rating and id. I've tried using groupby like this to get a multi-index Pandas series where there's a team_id and a cluster number corresponding to the number of instances that cluster appears for a certain team. It looks like this: this.

Unfortunately this removes the net rating, so I'm really not sure how to get all that info. I'm using plotly right now but if there's a solution with matplotlib that's fine.

This is the groupby code:

temp_df = pos_clusters.groupby(['TEAM_ID'])['Cluster'].value_counts().sort_index()

Thanks so much!

Derek O
  • 16,770
  • 4
  • 24
  • 43
Nicholas H
  • 23
  • 3
  • 1
    can you please post a sample of your DataFrame into the question as formatted text instead of an image? ([here](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) is a useful guide). this will make your code easier to run - thanks! – Derek O Dec 29 '21 at 21:54

0 Answers0