I have an issue about putting dataframe into to table and saving it as a png file.
To do that, I wrote some code blocks shown below.
df = pd.DataFrame({'count' : fdf.groupby(['year','Name']).size()}).reset_index()
df = df.sort_values(['year','count'], ascending=[True,False]).set_index(['year','Name'])
df = df.style.background_gradient(cmap='YlOrRd')
df
Here is my df
count
year Name
1950 a 3
b 3
1951 c 3
d 2
e 1
... ... ...
Then I tried to use this code snippet shown below to save result but it didn't work.
plt.figure(figsize=[15, 15])
ax = plt.subplot()
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
table(ax,f1_df_win_season.data)
plt.savefig('images/image1.png')
Although I can see all variables in table in JupyterNotebook, I couldn't see it in png file.
How can I fix it?
Here is my screenshot
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…