我在iPython Notebook和Pandas中迈出了第一步(并且未能为Google找到合适的关键词......)
有人可以告诉我如何改变桌子的样子吗?在这里,我希望日期不会被包装,缩短列标题以减少单元格的宽度(passenger_count)和舍入浮点数?
答案 0 :(得分:0)
这是我的熊猫设置偏好,希望它有所帮助。
import pandas as pd
# max no. of rows to display
pd.options.display.max_rows = 30
# max no. of columns to display
pd.options.display.max_columns = 6
# this limit the column width
pd.options.display.max_colwidth = 10
# this controls the floating rounding (precision, keep 4 decimals after .)
pd.options.display.precision = 5
您可以将这些命令放在IPython配置文件配置文件ipython_config.py
上,这样每次启动Qtconsole或Notebook会话时,这些设置都会自动加载。
c = get_config()
c.InteractiveShellApp.exec_lines = [
'import pandas as pd',
'pd.options.display.mpl_style = \'default\'',
'pd.options.display.max_rows = 30',
'pd.options.display.max_columns = 6',
'pd.options.display.expand_frame_repr = False',
'pd.options.display.max_colwidth = 28',
'pd.options.display.precision = 5',
'import numpy as np',
'np.set_printoptions(precision=4, linewidth=90, threshold=25)',
'import matplotlib.pyplot as plt'
]