美文网首页
pandas 使用问题汇总

pandas 使用问题汇总

作者: 在努力的Jie | 来源:发表于2020-02-08 11:04 被阅读0次
  1. <bound method NDFrame.head of


    1.png

    data.head为错误写法,改为data.head(),正确如下:


    2.png
  2. 解决 pandas 中打印 DataFrame 行列显示不全的问题
    在使用pandas的DataFrame打印时,如果表太长或者太宽会自动只给前后一些行列,但有时候因为一些需要,可能想看到所有的行列。
    所以只需要加一下的代码就行了。
#显示所有列
pd.set_option('display.max_columns', None)
#显示所有行
pd.set_option('display.max_rows', None)
#设置value的显示长度为100,默认为50
pd.set_option('max_colwidth',100)

4.用pandas展示数据输出时列名不能对齐

import pandas as pd
#这两个参数的默认设置都是False
pd.set_option('display.unicode.ambiguous_as_wide', True)
pd.set_option('display.unicode.east_asian_width', True)

相关文章

网友评论

      本文标题:pandas 使用问题汇总

      本文链接:https://www.haomeiwen.com/subject/ulpbxhtx.html