pandas中关于DataFrame行,列显示不完全(省略)的解决办法[通俗易懂]

pandas中关于DataFrame行,列显示不完全(省略)的解决办法[通俗易懂]有时候DataFrame中的行列数量太多,print打印出来会显示不完全。就像下图这样:列显示不全:行显示不全:添加如下代码,即可解决。#显示所有列pd.set_option(‘display.max_columns’,None)#显示所有行pd.set_option(‘display.max_rows’,None)#设置value的显示长度为100,默…

大家好,又见面了,我是你们的朋友全栈君。

有时候DataFrame中的行列数量太多,print打印出来会显示不完全。就像下图这样:

列显示不全:

这里写图片描述

行显示不全:

这里写图片描述

添加如下代码,即可解决。

#显示所有列
pd.set_option('display.max_columns', None)
#显示所有行
pd.set_option('display.max_rows', None)
#设置value的显示长度为100,默认为50
pd.set_option('max_colwidth',100)

根据自己的需要更改相应的设置即可。

ps:set_option()的所有属性:

Available options:

- display.[chop_threshold, colheader_justify, column_space, date_dayfirst,
  date_yearfirst, encoding, expand_frame_repr, float_format, height, large_repr]
- display.latex.[escape, longtable, repr]
- display.[line_width, max_categories, max_columns, max_colwidth,
  max_info_columns, max_info_rows, max_rows, max_seq_items, memory_usage,
  mpl_style, multi_sparse, notebook_repr_html, pprint_nest_depth, precision,
  show_dimensions]
- display.unicode.[ambiguous_as_wide, east_asian_width]
- display.[width]
- io.excel.xls.[writer]
- io.excel.xlsm.[writer]
- io.excel.xlsx.[writer]
- io.hdf.[default_format, dropna_table]
- mode.[chained_assignment, sim_interactive, use_inf_as_null]

Parameters
----------
pat : str
    Regexp which should match a single option.
    Note: partial matches are supported for convenience, but unless you use the
    full option name (e.g. x.y.z.option_name), your code may break in future
    versions if new options with similar names are introduced.
value :
    new value of option.

Returns
-------
None

Raises
------
OptionError if no such option exists

Notes
-----
The available options with its descriptions:

display.chop_threshold : float or None
    if set to a float value, all float values smaller then the given threshold
    will be displayed as exactly 0 by repr and friends.
    [default: None] [currently: None]

display.colheader_justify : 'left'/'right'
    Controls the justification of column headers. used by DataFrameFormatter.
    [default: right] [currently: right]

display.column_space No description available.
    [default: 12] [currently: 12]

display.date_dayfirst : boolean
    When True, prints and parses dates with the day first, eg 20/01/2005
    [default: False] [currently: False]

display.date_yearfirst : boolean
    When True, prints and parses dates with the year first, eg 2005/01/20
    [default: False] [currently: False]

display.encoding : str/unicode
    Defaults to the detected encoding of the console.
    Specifies the encoding to be used for strings returned by to_string,
    these are generally strings meant to be displayed on the console.
    [default: UTF-8] [currently: UTF-8]

display.expand_frame_repr : boolean
    Whether to print out the full DataFrame repr for wide DataFrames across
    multiple lines, `max_columns` is still respected, but the output will
    wrap-around across multiple "pages" if its width exceeds `display.width`.
    [default: True] [currently: True]

display.float_format : callable
    The callable should accept a floating point number and return
    a string with the desired format of the number. This is used
    in some places like SeriesFormatter.
    See formats.format.EngFormatter for an example.
    [default: None] [currently: None]

display.height : int
    Deprecated.
    [default: 60] [currently: 60]
    (Deprecated, use `display.max_rows` instead.)

display.large_repr : 'truncate'/'info'
    For DataFrames exceeding max_rows/max_cols, the repr (and HTML repr) can
    show a truncated table (the default from 0.13), or switch to the view from
    df.info() (the behaviour in earlier versions of pandas).
    [default: truncate] [currently: truncate]

display.latex.escape : bool
    This specifies if the to_latex method of a Dataframe uses escapes special
    characters.
    method. Valid values: False,True
    [default: True] [currently: True]

display.latex.longtable :bool
    This specifies if the to_latex method of a Dataframe uses the longtable
    format.
    method. Valid values: False,True
    [default: False] [currently: False]

display.latex.repr : boolean
    Whether to produce a latex DataFrame representation for jupyter
    environments that support it.
    (default: False)
    [default: False] [currently: False]

display.line_width : int
    Deprecated.
    [default: 80] [currently: 80]
    (Deprecated, use `display.width` instead.)

display.max_categories : int
    This sets the maximum number of categories pandas should output when
    printing out a `Categorical` or a Series of dtype "category".
    [default: 8] [currently: 8]

display.max_columns : int
    If max_cols is exceeded, switch to truncate view. Depending on
    `large_repr`, objects are either centrally truncated or printed as
    a summary view. 'None' value means unlimited.

    In case python/IPython is running in a terminal and `large_repr`
    equals 'truncate' this can be set to 0 and pandas will auto-detect
    the width of the terminal and print a truncated object which fits
    the screen width. The IPython notebook, IPython qtconsole, or IDLE
    do not run in a terminal and hence it is not possible to do
    correct auto-detection.
    [default: 20] [currently: 20]

display.max_colwidth : int
    The maximum width in characters of a column in the repr of
    a pandas data structure. When the column overflows, a "..."
    placeholder is embedded in the output.
    [default: 50] [currently: 200]

display.max_info_columns : int
    max_info_columns is used in DataFrame.info method to decide if
    per column information will be printed.
    [default: 100] [currently: 100]

display.max_info_rows : int or None
    df.info() will usually show null-counts for each column.
    For large frames this can be quite slow. max_info_rows and max_info_cols
    limit this null check only to frames with smaller dimensions than
    specified.
    [default: 1690785] [currently: 1690785]

display.max_rows : int
    If max_rows is exceeded, switch to truncate view. Depending on
    `large_repr`, objects are either centrally truncated or printed as
    a summary view. 'None' value means unlimited.

    In case python/IPython is running in a terminal and `large_repr`
    equals 'truncate' this can be set to 0 and pandas will auto-detect
    the height of the terminal and print a truncated object which fits
    the screen height. The IPython notebook, IPython qtconsole, or
    IDLE do not run in a terminal and hence it is not possible to do
    correct auto-detection.
    [default: 60] [currently: 60]

display.max_seq_items : int or None
    when pretty-printing a long sequence, no more then `max_seq_items`
    will be printed. If items are omitted, they will be denoted by the
    addition of "..." to the resulting string.

    If set to None, the number of items to be printed is unlimited.
    [default: 100] [currently: 100]

display.memory_usage : bool, string or None
    This specifies if the memory usage of a DataFrame should be displayed when
    df.info() is called. Valid values True,False,'deep'
    [default: True] [currently: True]

display.mpl_style : bool
    Setting this to 'default' will modify the rcParams used by matplotlib
    to give plots a more pleasing visual style by default.
    Setting this to None/False restores the values to their initial value.
    [default: None] [currently: None]

display.multi_sparse : boolean
    "sparsify" MultiIndex display (don't display repeated
    elements in outer levels within groups)
    [default: True] [currently: True]

display.notebook_repr_html : boolean
    When True, IPython notebook will use html representation for
    pandas objects (if it is available).
    [default: True] [currently: True]

display.pprint_nest_depth : int
    Controls the number of nested levels to process when pretty-printing
    [default: 3] [currently: 3]

display.precision : int
    Floating point output precision (number of significant digits). This is
    only a suggestion
    [default: 6] [currently: 6]

display.show_dimensions : boolean or 'truncate'
    Whether to print out dimensions at the end of DataFrame repr.
    If 'truncate' is specified, only print out the dimensions if the
    frame is truncated (e.g. not display all rows and/or columns)
    [default: truncate] [currently: truncate]

display.unicode.ambiguous_as_wide : boolean
    Whether to use the Unicode East Asian Width to calculate the display text
    width.
    Enabling this may affect to the performance (default: False)
    [default: False] [currently: False]

display.unicode.east_asian_width : boolean
    Whether to use the Unicode East Asian Width to calculate the display text
    width.
    Enabling this may affect to the performance (default: False)
    [default: False] [currently: False]

display.width : int
    Width of the display in characters. In case python/IPython is running in
    a terminal this can be set to None and pandas will correctly auto-detect
    the width.
    Note that the IPython notebook, IPython qtconsole, or IDLE do not run in a
    terminal and hence it is not possible to correctly detect the width.
    [default: 80] [currently: 80]

io.excel.xls.writer : string
    The default Excel writer engine for 'xls' files. Available options:
    'xlwt' (the default).
    [default: xlwt] [currently: xlwt]

io.excel.xlsm.writer : string
    The default Excel writer engine for 'xlsm' files. Available options:
    'openpyxl' (the default).
    [default: openpyxl] [currently: openpyxl]

io.excel.xlsx.writer : string
    The default Excel writer engine for 'xlsx' files. Available options:
    'xlsxwriter' (the default), 'openpyxl'.
    [default: xlsxwriter] [currently: xlsxwriter]

io.hdf.default_format : format
    default format writing format, if None, then
    put will default to 'fixed' and append will default to 'table'
    [default: None] [currently: None]

io.hdf.dropna_table : boolean
    drop ALL nan rows when appending to a table
    [default: False] [currently: False]

mode.chained_assignment : string
    Raise an exception, warn, or no action if trying to use chained assignment,
    The default is warn
    [default: warn] [currently: warn]

mode.sim_interactive : boolean
    Whether to simulate interactive mode for purposes of testing
    [default: False] [currently: False]

mode.use_inf_as_null : boolean
    True means treat None, NaN, INF, -INF as null (old way),
    False means None and NaN are null, but INF, -INF are not null
    (new way).
    [default: False] [currently: False]
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/159626.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • directx修复工具是干嘛的_win10自带dll修复

    directx修复工具是干嘛的_win10自带dll修复最后更新:2019-9-5ForEnglishversion,pleaserefertothebottomofthispage.DirectX修复工具最新版:DirectXRepairV3.9标准版NEW!版本号:V3.9.0.29371大小:30.7MB/7z格式压缩,98.7MB/zip格式压缩,231MB/解压后其他版本:增强版在…

    2022年4月20日
    226
  • 服务器机房排风系统图,机房新风系统和排风系统的方案设计方法-20210628031546.pdf-原创力文档…

    服务器机房排风系统图,机房新风系统和排风系统的方案设计方法-20210628031546.pdf-原创力文档…______________________________________________________________________________________________________________新风系统的方案设计方法:设计方案时,即便再简单的方案,我们也应该先做方案、再扒图纸、作出预算的程序,这样我们就不会丢项、报错。复杂的项目,应该编制联系人表格;方便现场沟通…

    2022年5月22日
    53
  • 软件工程师待遇怎么样?软件工程师薪水到底有多高?「建议收藏」

    软件工程师待遇怎么样?软件工程师薪水到底有多高?「建议收藏」随着技术不断进步,行业对软件开发技能的需求急剧上升。在此情况下,软件工程师(程序员)薪水上涨便很正常。通常来说,个人薪水是高是低,则与自身积累的经验、所处的地点以及产业分不开。据国际调研机构IDC在报告中公开的数据:2018年,全球有2230万名的软件工程师;其中,全职程序员1165万名,兼职人员635万名,非专业人员430万名。美国拥有最多的软件工程师,651017人;其次是中国,183…

    2022年9月2日
    3
  • 小强学Python+OpenCV之-1.3绘图

    小强学Python+OpenCV之-1.3绘图

    2022年3月3日
    47
  • 俞敏洪沉默,新东方落泪

    俞敏洪沉默,新东方落泪据传,早些年以新东方三位创始人创业为主线故事,风靡一时的电影《中国合伙人》开拍前,剧组曾向电影男主角的原型人物俞敏洪,提出了友好交流的请求。俞敏洪提出最大的意见是:可不可以别把我拍得这么“土鳖”?几十年来,号称农村出身的寒门子弟俞敏洪,其身份发生了重大变化。在公开场合里,他对自己的身世表露出深深的自卑。另一方面,他又被誉为中国留学教父,俨然成为一个农村“凤凰男”逆袭成精英阶级的典型代表。当然,俞敏洪还是新东方的创始人,中国商业洪流里响当当的传奇。“我吃一碗兰州拉面都很开心”。可就是这样一个人,对财

    2022年9月13日
    0
  • 《SiamFC++:Towards Robust and Accurate Visual Tracking with Target Estimation Guidelines》论文笔记

    《SiamFC++:Towards Robust and Accurate Visual Tracking with Target Estimation Guidelines》论文笔记参考代码:video_analyst1.概述导读:这篇文章指出之前的一些跟踪算法没有深入讨论针对跟踪任务的实质,很多时候只是在某些点上进行突破,因而最后方法的性能总是有局限性的。对此文章深入分析了跟踪网络的特性,因而对跟踪网络的设计提出了4点建议:G1(目标位置估计和目标判别需要接耦,分别具有各自的分支)/G2(目标判别置信度不能与实际相模糊)/G3(不能依赖数据分布等先验知识,否则导致泛化性鲁棒性不强)/G4(目标位置的估计应该准确)。正是基于上的4点设计指导,文章设计了SiamFC++网络,在5

    2022年9月27日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号