Need some help figuring out how to fit this...
df = pd.read_csv('data.csv')
df1 = df.pivot(index='Name', columns='Years', values='Apples')
sns.heatmap(df1)
The data.csv looks like this:
Name | Years | Apples |
---|---|---|
Henry | 2020 | 2 |
Bob | 2020 | 2 |
Johnny | 2020 | 1 |
Henry | 2021 | 6 |
Bob | 2021 | 2 |
Johnny | 2021 | 1 |
Now when I try to do a heatmap using Seaborn, it prompts out a Value Error stating I can't convert "Henry" from a string to a float.
I figured after googling that I need to pivot the dataframe. Unfortunately, it also alphabetically sorted the "Names" column. Is it possible to maintain the same order as "Henry", "Bob", and "Johnny" instead?
Heatmap Screenshot