0

pandas is so popular, so many questions and answers so I have a huge mess in my head

you can see it by triple 'so' in one sentence

I have pandas df made from IMDB tsv files - there three columns - 'season', 'episode', 'rating'. I want to receive a "rating map" with season numbers as columns and episode numbers as rows. I tried to draw it in the picture.

df_episodes = DataFrame({'season':[1,1,1,2,2,2],'episode':[1,2,3,1,2,3],'rating':[3,4,5,6,7,8]})

Is there any common way to make this conversion?

Started with making new dataframe

df = DataFrame(columns=[df_episodes.season])

but don't know how to make column names unique - now I have '1', '1','1','2','2',...

then I planned to iterate within df

enter image description here

dad
  • 15
  • 5

0 Answers0