横向不换行
当一行太长(列数多或列名宽)时,pandas 会折行显示
<一>强制 pandas 不折行,一次性显示完整宽表:
import pandas as pd
# 放在代码最前面,只需一次设置
pd.set_option('display.expand_frame_repr', False) # 不允许换行
pd.set_option('display.width', None) # 自动适应终端宽度
# 你的输出语句
cols = ['Age', 'Purchase Amount (UsD)', 'Review Rating', 'Previous Purchases']
print(df[cols].describe())
<二>把列名缩短
print(df[cols].describe().rename(columns={
'Purchase Amount (UsD)': 'Amount',
'Review Rating': 'Rating',
'Previous Purchases': 'PrevPurch'
}))