在熊猫上工作描述功能。足够简单的代码:
df ['Revenue']。describe()
输出是:
完善。我的问题是我希望能够将这些数据另存为png或表,以便可以放置在单个页面中。这是针对我的EDA(探索性数据分析),我有6个主要图表或要对每个功能进行评估的信息。每个图表将是一个单独的png文件。然后,我将合并为一个pdf文件。我会迭代300多种功能,因此一次执行一项功能不是一个特别的选择,因为它每月进行一次。
如果您知道将表另存为png或其他类似文件格式的方法,那就太好了。谢谢你的样子
小智 8
另存为csv或xlsx文件
您可以使用to_csv(“ filename.csv”)或to_excel(“ filename.xlsx”)方法将文件保存为逗号分隔的格式,然后根据需要在Excel中对其进行操作/格式化。例:
df['Revenue'].describe().to_csv("my_description.csv")
Run Code Online (Sandbox Code Playgroud)
另存为PNG文件
如评论中所述,这篇文章解释了如何通过matplot lib将pandas数据帧保存到png文件中。在您的情况下,这应该起作用:
import matplotlib.pyplot as plt
from pandas.plotting import table
desc = df['Revenue'].describe()
#create a subplot without frame
plot = plt.subplot(111, frame_on=False)
#remove axis
plot.xaxis.set_visible(False)
plot.yaxis.set_visible(False)
#create the table plot and position it in the upper left corner
table(plot, desc,loc='upper right')
#save the plot as a png file
plt.savefig('desc_plot.png')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6372 次 |
| 最近记录: |