pandas options and settings

来源:互联网 发布:淘宝电动车便宜 编辑:程序博客网 时间:2024/06/06 10:58
pd.set_option(’precision’, 5)`
In [46]: pd.set_option(’max_colwidth’, 6)In [47]: dfOut[47]:  0     1   2     30 foo   bar bim   un...1 horse cow ba... apple
In [55]: df=pd.DataFrame(np.random.choice([0,1,np.nan],size=(10,10)))In [56]: dfOut[56]:  0 1 2 3 4 5 6 7 8 90 0 1 1 0 1 1 0 NaN 1 NaN1 1 NaN 0 0 1 1 NaN 1 0 12 NaN NaN NaN 1 1 0 NaN 0 1 NaN3 0 1 1 NaN 0 NaN 1 NaN NaN 04 0 1 0 0 1 0 0 NaN 0 05 0 NaN 1 NaN NaN NaN NaN 0 1 NaN6 0 1 0 0 NaN 1 NaN NaN 0 NaN7 0 NaN 1 1 NaN 1 1 1 1 NaN8 0 0 NaN 0 NaN 1 0 0 NaN NaN9 NaN NaN 0 NaN NaN NaN 0 1 1 NaN
display.chop_threshold sets at what level pandas rounds to zero when it displays a Series of DataFrame.Note, this does not effect the precision at which the number is stored.In [67]: df=pd.DataFrame(np.random.randn(6,6))In [68]: pd.set_option(’chop_threshold’, 0)In [69]: dfOut[69]:  0      1     2      3      4     50 -0.198 0.966 -1.523 -0.117 0.296 -1.0481 1.641 1.906 2.772 0.089 -1.144 -0.6332 0.925 -0.006 -0.820 -0.601 -1.039 0.8253 -0.824 -0.338 -0.928 -0.840 0.249 -0.1094 0.432 -0.461 0.337 -3.208 -1.536 0.4105 -0.673 -0.741 -0.111 -2.673 0.864 0.061In [70]: pd.set_option(’chop_threshold’, .5)In [71]: dfOut[71]:  0     1     2      3     4     50 0.000 0.966 -1.523 0.000 0.000 -1.0481 1.641 1.906 2.772 0.000 -1.144 -0.6332 0.925 0.000 -0.820 -0.601 -1.039 0.8253 -0.824 0.000 -0.928 -0.840 0.000 0.0004 0.000 0.000 0.000 -3.208 -1.536 0.0005 -0.673 -0.741 0.000 -2.673 0.864 0.000
In [74]: pd.set_option(’colheader_justify’, ’right’)In [75]: dfOut[75]:      A    B C0 0.933  0.3 01 0.289  0.2 02 1.325  0.2 03 0.589  0.7 04 0.531  0.1 05 -1.199 0.7 0In [76]: pd.set_option(’colheader_justify’, ’left’)In [77]: dfOut[77]:  A      B   C0 0.933  0.3 01 0.289  0.2 02 1.325  0.2 03 0.589  0.7 04 0.531  0.1 05 -1.199 0.7 0
0 0
原创粉丝点击