I have a one-hot encoded data frame that is similar to the one below:
review_score | Action & Adventure | Classic Movies | TV Comedies | TV Mysteries |
---|---|---|---|---|
4 | 0 | 0 | 1 | 0 |
10 | 1 | 0 | 0 | 0 |
5 | 1 | 0 | 0 | 0 |
7 | 0 | 1 | 0 | 0 |
8 | 0 | 0 | 1 | 0 |
7 | 0 | 0 | 0 | 1 |
it contains 40+ columns and I do not think it would be feasible to put every column name into the functions.
How can I pivot or rearrange the table so it looks something like the one below:
Genre | review_score |
---|---|
Action & Adventure | 10 |
Action & Adventure | 5 |
Classic Movies | 7 |
TV Comedies | 4 |
TV Comedies | 8 |
TV Mysteries | 7 |
I want each genre to have a row for each review score given in order to plot a boxplot
I have tried melt and wide_to_long functions but cannot get the desired data frame. Please advice!