亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

淺談pandas中DataFrame關(guān)于顯示值省略的解決方法

 更新時(shí)間:2018年04月08日 16:16:44   作者:曉東邪  
下面小編就為大家分享一篇淺談pandas中DataFrame關(guān)于顯示值省略的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

python的pandas庫(kù)是一個(gè)非常好的工具,里面的DataFrame更是常用且好用,最近是越用越覺(jué)得設(shè)計(jì)的漂亮,pandas的很多細(xì)節(jié)設(shè)計(jì)的都非常好,有待使用過(guò)程中發(fā)掘。

好了,發(fā)完感慨,說(shuō)一下最近DataFrame遇到的一個(gè)細(xì)節(jié):

在使用DataFrame中有時(shí)候會(huì)遇到表格中的value顯示不完全,像下面這樣:

In:
import pandas as pd
longString = u'''真正的科學(xué)家應(yīng)當(dāng)是個(gè)幻想家;誰(shuí)不是幻想家,誰(shuí)就只能把自己稱(chēng)為實(shí)踐家。人生的磨難是很多的,
所以我們不可對(duì)于每一件輕微的傷害都過(guò)于敏感。在生活磨難面前,精神上的堅(jiān)強(qiáng)和無(wú)動(dòng)于衷是我們抵抗罪惡和人生意外的最好武器。'''
pd.DataFrame({'word':[longString]})

輸出如下:

可以看到,顯示值長(zhǎng)度為50個(gè)后就出現(xiàn)了省略了,這個(gè)因?yàn)镈ataFrame默認(rèn)的顯示長(zhǎng)度為50,不過(guò)可以改默認(rèn)設(shè)置:

pd.set_option('max_colwidth',200)
pd.DataFrame({'word':[longString]})

通過(guò)設(shè)置就可以改變顯示長(zhǎng)度了。

關(guān)于set_option所有的參數(shù)介紹如下:

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]

以上這篇淺談pandas中DataFrame關(guān)于顯示值省略的解決方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python辦公自動(dòng)化之將任意文件轉(zhuǎn)為PDF格式

    Python辦公自動(dòng)化之將任意文件轉(zhuǎn)為PDF格式

    這種把某個(gè)文件轉(zhuǎn)為pdf枯燥無(wú)聊的工作,既沒(méi)有什么技術(shù)含量又累. 今天辰哥就教大家將任意文件批量轉(zhuǎn)為PDF,這里以日常辦公的word、excel、ppt為例,這三種格式的文件轉(zhuǎn)為PDF.需要的朋友可以參考下
    2021-06-06
  • pycharm終端無(wú)法激活conda環(huán)境的解決辦法

    pycharm終端無(wú)法激活conda環(huán)境的解決辦法

    如果您在PyCharm終端中無(wú)法激活conda環(huán)境,可能是由于PyCharm沒(méi)有正確配置conda解釋器,這篇文章主要給大家介紹了關(guān)于pycharm終端無(wú)法激活conda環(huán)境的解決辦法,需要的朋友可以參考下
    2023-09-09
  • python實(shí)現(xiàn)對(duì)象列表根據(jù)某個(gè)屬性排序的方法詳解

    python實(shí)現(xiàn)對(duì)象列表根據(jù)某個(gè)屬性排序的方法詳解

    這篇文章主要介紹了python實(shí)現(xiàn)對(duì)象列表根據(jù)某個(gè)屬性排序的方法,結(jié)合具體實(shí)例形式詳細(xì)分析了Python對(duì)象列表遍歷、排序的兩種常見(jiàn)操作技巧,需要的朋友可以參考下
    2019-06-06
  • 利用python?pywifi實(shí)現(xiàn)破解WiFi密碼

    利用python?pywifi實(shí)現(xiàn)破解WiFi密碼

    家里沒(méi)有怎么辦,只要你會(huì)Python,辦法總比困難多,本文就利用pywifi?這個(gè)庫(kù)實(shí)驗(yàn)一下如何破解Wi-Fi?密碼,注意,該方法僅可用來(lái)研究學(xué)習(xí)所用,需要的朋友可以參考下
    2024-03-03
  • python3的輸入方式及多組輸入方法

    python3的輸入方式及多組輸入方法

    今天小編就為大家分享一篇python3的輸入方式及多組輸入方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-10-10
  • Python 多線程抓取圖片效率對(duì)比

    Python 多線程抓取圖片效率對(duì)比

    Python由于有全鎖局的存在,并不能利用多核優(yōu)勢(shì)。所以,如果你的多線程進(jìn)程是CPU密集型的,那多線程并不能帶來(lái)效率上的提升,相反還可能會(huì)因?yàn)榫€程的頻繁切換,導(dǎo)致效率下降;如果是IO密集型,多線程進(jìn)程可以利用IO阻塞等待時(shí)的空閑時(shí)間執(zhí)行其他線程,提升效率。
    2016-02-02
  • Python設(shè)計(jì)模式之抽象工廠模式

    Python設(shè)計(jì)模式之抽象工廠模式

    這篇文章主要為大家詳細(xì)介紹了Python設(shè)計(jì)模式之抽象工廠模式,感興趣的小伙伴們可以參考一下
    2016-08-08
  • Python中的list.sort()方法和函數(shù)sorted(list)

    Python中的list.sort()方法和函數(shù)sorted(list)

    這篇文章主要介紹了Python中的list.sort()方法和函數(shù)sorted(list),sort()是列表的方法,修改原列表使得它按照大小排序,沒(méi)有返回值,返回None
    2022-08-08
  • Python爬取OPGG上英雄聯(lián)盟英雄勝率及選取率信息的操作

    Python爬取OPGG上英雄聯(lián)盟英雄勝率及選取率信息的操作

    這篇文章主要介紹了Python爬取OPGG上英雄聯(lián)盟英雄勝率及選取率信息的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-04-04
  • 使用Matplotlib將圖片保存為.tiff格式

    使用Matplotlib將圖片保存為.tiff格式

    這篇文章主要介紹了使用Matplotlib將圖片保存為.tiff格式問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-09-09

最新評(píng)論