【发布时间】:2020-03-27 14:34:40
【问题描述】:
def inspect_df(df):
results = (df.head(), df.tail(), df.info(), df.describe(include='all'),)
for result in results:
display(result)
df = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
inspect_df(df)
请注意,df.info() 是结果中的第三项。然而,这首先呈现信息的输出,然后是其余的项目。如何让它以指定的顺序打印输出?
但是,如果我显式调用显示(没有列表),它会正确呈现:
def inspect_df(df):
display(df.head())
display(df.tail())
display(df.info())
display(df.describe(include='all'))
df = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
inspect_df(df)
【问题讨论】: