0

I have a video game dataset that I downloaded from data.world.The dataset includes columns with the names of the video games, the years & sales in multiple regions. I want to find the top sold game every year. I used the following code

‍‍‍ group=vidgame_3.groupby(["Year"])["Global_Sales"].max() ‍‍

This code returned the year & the max sale but it omitted the name column which I want to include as well. How do I include another column.

The dataset has 3 columns(Name,Year,Global Sales) that I am concerned with. I want to calcuate a tabel where I get the highest sold game by year & the name as well, When I use the group function by year, I get the year and the amount but not the name of the game.

  • `vidgame_3.groupby(["Year"]).agg({'Global_Sales': 'max'})` or `vidgame_3.groupby(["Year"])["Global_Sales"].max().reset_index()` – Trenton McKinney Aug 03 '20 at 18:16
  • Does this answer your question? [Converting a Pandas GroupBy output from Series to DataFrame](https://stackoverflow.com/questions/10373660/converting-a-pandas-groupby-output-from-series-to-dataframe) – Trenton McKinney Aug 03 '20 at 18:20

0 Answers0