When I execute this code:
plt.figure(figsize=(12,8))
ax = sns.heatmap(result, annot=True, linewidths=.5) #YlGnBu
plt.ylabel('Hour', fontsize=12)
plt.xlabel('Id', fontsize=12)
plt.xticks(rotation='vertical')
plt.show()
I get this error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 11: ordinal not in range(128)
Cannot understand how to resolve this issue.
This is an extract from my dataframe df
:
df =
Id Hour FREQ
1 17 19
1 18 16
1 19 2
2 17 49
Then I create a pivot table result
as follows:
result = df.pivot("Hour", "CameraId", "FREQ")
UPDATE:
The dataframe df
was obtained as follows (if it may help finding an issue):
df = df_original.groupby([df_original['Id'], df_original['Hour'], df_original['Date']]).size()
#groupby by ID and hours
df1 = df.groupby(level=[0,1]).mean()
mux = pd.MultiIndex.from_product([df1.index.levels[0], df1.index.levels[1]],names=df1.index.names)
df = df1.reindex(mux, fill_value=0).reset_index(name='FREQ')
norm = plt.Normalize(df["FREQ"].values.min(), df["FREQ"].values.max())
colors = plt.cm.YlGnBu(norm(gr_vol_1["FREQ"]))