我想打印我的数据框。不幸的是,图片只显示了数据帧的 2 行,而不是 20 行,下表如下,并且还有一个巨大的空白区域。有人可以帮助我获取数据帧的所有 20 行吗?
这是来源How to save a pandas DataFrame table as a png
import pandas as pd
import matplotlib.pyplot as plt
from pandas.plotting import table # EDIT: see deprecation warnings below
from pathlib import Path
PATH_DATA = "../data"
PATH_RETAILROCKET = Path(PATH_DATA,"retailrocket/retailrocket/events.csv")
# RetailRocket
print(PATH_RETAILROCKET)
df = pd.read_csv(Path(PATH_RETAILROCKET))
df = df.head(20)
ax = plt.subplot(111, frame_on=False) # no visible frame
ax.xaxis.set_visible(False) # hide the x axis
ax.yaxis.set_visible(False) # hide the y axis
table(ax, df) # where df is your data frame
plt.savefig('mytable.png')
桃花长相依
相关分类