0

DataFrame of survey results

The above dataframe contains survey results where people rated their movie genres from 1 to 5. I want to plot a bar chart which shows how many males and females liked each movie genre. I used the following code.

req_data = req_data[['Movies', 'Horror', 'Thriller', 'Comedy', 'Romantic', 'Sci-fi', 'War', 'Fantasy/Fairy tales',
'Animated','Documentary', 'Western', 'Action', 'History','Age', 'Gender']].dropna()

movie = req_data.loc[(req_data['Movies'] >= 3) & (req_data['Gender'])].copy()

movie = movie[['Movies','Gender']]

movie_data = movie['Gender'].value_counts().to_frame()
movie_data = movie_data.reset_index()
movie_data.columns=['Gender','counts']

horror = req_data.loc[(req_data['Horror'] >= 3) & (req_data['Gender'])].copy()

horror = horror[['Horror','Gender']]

horror_data = horror['Gender'].value_counts().to_frame()
horror_data = horror_data.reset_index()
horror_data.columns=['Gender','counts']

movie_data.plot(x='Gender', y= 'counts',kind = 'bar')
horror_data.plot(x='Gender', y='counts',kind = 'bar')

plt.show()

When use this code I can only get chart of one genre(in this case, chart of 'movie' ). How can I get a chart which shows every movie genre in one?

[In the above code I used >=3 to obtain respondents who liked movies]

Henry Ecker
  • 31,792
  • 14
  • 29
  • 50
hafiz kk
  • 3
  • 4
  • 1
    Please do not link or embed external images of source data. Images make it difficult to efficiently assist you as they cannot be copied and offer poor usability as they cannot be searched. See: [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/q/285551/15497888) If you need assistance formatting a small sample of your DataFrame as a copyable piece of code for SO see [How to make good reproducible pandas examples](https://stackoverflow.com/q/20109391/15497888). – Henry Ecker Mar 11 '22 at 17:23

0 Answers0