0

enter image description here

I wish to group the data by director names and release_ year to see how many times each director's name appears yearly.

possizola
  • 25
  • 3
  • 1
    https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.groupby.html – AKX Jul 01 '23 at 14:06
  • Does this answer your question? [Get statistics for each group (such as count, mean, etc) using pandas GroupBy?](https://stackoverflow.com/questions/19384532/get-statistics-for-each-group-such-as-count-mean-etc-using-pandas-groupby) – Derek O Jul 01 '23 at 15:12
  • 1
    Please do not post pictures of code. The code should be pasted into your question in a code block. – jared Jul 01 '23 at 16:41

1 Answers1

0

Group the data by 'director_name' and 'release_year' and count the occurrences

grouped_data = df.groupby(['director_name', 'release_year']).size().reset_index(name='count')
Himanshu Panwar
  • 216
  • 2
  • 7
Dejene T.
  • 973
  • 8
  • 14