中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

網(wǎng)站服務(wù)合同用交印花稅嗎點(diǎn)擊器 百度網(wǎng)盤

網(wǎng)站服務(wù)合同用交印花稅嗎,點(diǎn)擊器 百度網(wǎng)盤,做網(wǎng)站內(nèi)嵌地圖,網(wǎng)站建設(shè)及管理基本要求65_Pandas顯示設(shè)置(小數(shù)位數(shù)、有效數(shù)字、最大行/列數(shù)等) 本文介紹了使用 print() 函數(shù)顯示 pandas.DataFrame、pandas.Series 等時(shí)如何更改設(shè)置(小數(shù)點(diǎn)后位數(shù)、有效數(shù)字、最大行/列數(shù)等)。 有關(guān)如何檢查、更改和重置設(shè)置值的詳細(xì)…

65_Pandas顯示設(shè)置(小數(shù)位數(shù)、有效數(shù)字、最大行/列數(shù)等)

本文介紹了使用 print() 函數(shù)顯示 pandas.DataFrame、pandas.Series 等時(shí)如何更改設(shè)置(小數(shù)點(diǎn)后位數(shù)、有效數(shù)字、最大行/列數(shù)等)。

有關(guān)如何檢查、更改和重置設(shè)置值的詳細(xì)信息,請(qǐng)參閱下面的文章。設(shè)置更改僅在同一代碼(腳本)內(nèi)有效。它不會(huì)被永久重寫,并在其他代碼中再次成為默認(rèn)設(shè)置。即使在同一代碼中,您也可以臨時(shí)更改 with 塊中的設(shè)置。

這里說明的只是顯示時(shí)的設(shè)置,原始數(shù)據(jù)值本身不會(huì)改變。如果您想對(duì)數(shù)字進(jìn)行四舍五入或?qū)⑵滢D(zhuǎn)換為指定格式的字符串,請(qǐng)參閱下面的文章。

  • 63_Pandas中數(shù)字的四舍五入

導(dǎo)入以下庫。 NumPy 用于生成 pandas.DataFrame。請(qǐng)注意,根據(jù) pandas 的版本,設(shè)置的默認(rèn)值可能會(huì)有所不同。

import pandas as pd
import numpy as npprint(pd.__version__)
# 0.23.0

這里我們將解釋與顯示相關(guān)的主要項(xiàng)目。

  • 小數(shù)點(diǎn)右邊的位數(shù):display. precision
  • 有效數(shù)字:display.float_format
  • 關(guān)于四舍五入的注意事項(xiàng)
  • 最大顯示行數(shù):display.max_rows
  • 最大顯示列數(shù):display.max_columns
  • 默認(rèn)顯示的行數(shù)和列數(shù):display.show_dimensions
  • 總體最大顯示寬度:display.width
  • 每列最大顯示寬度:display.max_colwidth
  • 列名顯示的右對(duì)齊/左對(duì)齊:display.colheader_justify

小數(shù)點(diǎn)右邊的位數(shù):display. precision

小數(shù)點(diǎn)后的位數(shù)用display. precision設(shè)置。 默認(rèn)為 6,無論整數(shù)部分有多少位,小數(shù)點(diǎn)以下的位數(shù)都將是指定的數(shù)字。盡管被省略并顯示,原始數(shù)據(jù)值也保留了后續(xù)數(shù)字的信息。

print(pd.options.display.precision)
# 6s_decimal = pd.Series([123.456, 12.3456, 1.23456, 0.123456, 0.0123456, 0.00123456])print(s_decimal)
# 0    123.456000
# 1     12.345600
# 2      1.234560
# 3      0.123456
# 4      0.012346
# 5      0.001235
# dtype: float64print(s_decimal[5])
# 0.00123456

根據(jù)display. precision的設(shè)置值,格式(顯示格式)發(fā)生變化并變?yōu)橹笖?shù)表示法。

pd.options.display.precision = 4print(s_decimal)
# 0    123.4560
# 1     12.3456
# 2      1.2346
# 3      0.1235
# 4      0.0123
# 5      0.0012
# dtype: float64pd.options.display.precision = 2print(s_decimal)
# 0    1.23e+02
# 1    1.23e+01
# 2    1.23e+00
# 3    1.23e-01
# 4    1.23e-02
# 5    1.23e-03
# dtype: float64

如果要控制格式,請(qǐng)使用 display.float_format,如下所述。

有效數(shù)字:display.float_format

用display. precision可以設(shè)置的是小數(shù)點(diǎn)后的位數(shù),如果想指定包括整數(shù)部分在內(nèi)的有效數(shù)字(significantdigits)的個(gè)數(shù),則使用display.float_format。默認(rèn)為“None”。

print(pd.options.display.float_format)
# None

display.float_format 指定一個(gè)可調(diào)用對(duì)象(函數(shù)、方法等),該對(duì)象將浮點(diǎn)float類型轉(zhuǎn)換為任何格式的字符串?;旧?#xff0c;您可以考慮指定字符串方法format()。

格式規(guī)范字符串’.[位數(shù)]f’可用于指定小數(shù)點(diǎn)后的位數(shù),'.[位數(shù)]g’可用于指定總位數(shù)(有效數(shù)字) )。

pd.options.display.float_format = '{:.2f}'.formatprint(s_decimal)
# 0   123.46
# 1    12.35
# 2     1.23
# 3     0.12
# 4     0.01
# 5     0.00
# dtype: float64pd.options.display.float_format = '{:.4g}'.formatprint(s_decimal)
# 0      123.5
# 1      12.35
# 2      1.235
# 3     0.1235
# 4    0.01235
# 5   0.001235
# dtype: float64

如果要顯示相同的位數(shù),請(qǐng)使用“.[位數(shù)]e”來使用指數(shù)表示法。由于整數(shù)部分始終為 1 位,因此有效數(shù)字為設(shè)定的位數(shù) + 1。

pd.options.display.float_format = '{:.4e}'.formatprint(s_decimal)
# 0   1.2346e+02
# 1   1.2346e+01
# 2   1.2346e+00
# 3   1.2346e-01
# 4   1.2346e-02
# 5   1.2346e-03
# dtype: float64

由于可以使用任何格式規(guī)范字符串,因此也可以進(jìn)行左對(duì)齊和百分比顯示等對(duì)齊方式,如下所示。關(guān)于如何指定格式等詳細(xì)信息,請(qǐng)參見上面format()的相關(guān)文章。

pd.options.display.float_format = '{: <10.2%}'.formatprint(s_decimal)
# 0   12345.60% 
# 1   1234.56%  
# 2   123.46%   
# 3   12.35%    
# 4   1.23%     
# 5   0.12%     
# dtype: float64

關(guān)于四舍五入的注意事項(xiàng)

display. precision 和 display.float_format 對(duì)值進(jìn)行四舍五入,但不是一般四舍五入,而是四舍五入為偶數(shù);例如,0.5 四舍五入為 0。

df_decimal = pd.DataFrame({'s': ['0.4', '0.5', '0.6', '1.4', '1.5', '1.6'],'f': [0.4, 0.5, 0.6, 1.4, 1.5, 1.6]})pd.options.display.float_format = '{:.0f}'.formatprint(df_decimal)
#      s  f
# 0  0.4  0
# 1  0.5  0
# 2  0.6  1
# 3  1.4  1
# 4  1.5  2
# 5  1.6  2

另外,在四舍五入到小數(shù)點(diǎn)時(shí),根據(jù)該值,可以四舍五入到偶數(shù),也可以四舍五入到奇數(shù)。

df_decimal2 = pd.DataFrame({'s': ['0.04', '0.05', '0.06', '0.14', '0.15', '0.16'],'f': [0.04, 0.05, 0.06, 0.14, 0.15, 0.16]})pd.options.display.float_format = '{:.1f}'.formatprint(df_decimal2)
#       s   f
# 0  0.04 0.0
# 1  0.05 0.1
# 2  0.06 0.1
# 3  0.14 0.1
# 4  0.15 0.1
# 5  0.16 0.2

這是由于浮點(diǎn)數(shù)的處理造成的。

最大顯示行數(shù):display.max_rows

最大顯示行數(shù)通過display.max_rows 設(shè)置。如果行數(shù)超過display.max_rows的值,則省略中間部分,顯示開頭和結(jié)尾。 默認(rèn)值為 60。

print(pd.options.display.max_rows)
# 60df_tall = pd.DataFrame(np.arange(300).reshape((100, 3)))pd.options.display.max_rows = 10print(df_tall)
#       0    1    2
# 0     0    1    2
# 1     3    4    5
# 2     6    7    8
# 3     9   10   11
# 4    12   13   14
# ..  ...  ...  ...
# 95  285  286  287
# 96  288  289  290
# 97  291  292  293
# 98  294  295  296
# 99  297  298  299
# [100 rows x 3 columns]

如果只想顯示開頭或結(jié)尾,請(qǐng)使用 head() 或 tail()。同樣在這種情況下,如果行數(shù)超過display.max_rows的值,則中間部分被省略。

  • 18_Pandas.DataFrame,取得Series的頭和尾(head和tail)
print(df_tall.head(10))
#     0   1   2
# 0   0   1   2
# 1   3   4   5
# 2   6   7   8
# 3   9  10  11
# 4  12  13  14
# 5  15  16  17
# 6  18  19  20
# 7  21  22  23
# 8  24  25  26
# 9  27  28  29print(df_tall.head(20))
#      0   1   2
# 0    0   1   2
# 1    3   4   5
# 2    6   7   8
# 3    9  10  11
# 4   12  13  14
# ..  ..  ..  ..
# 15  45  46  47
# 16  48  49  50
# 17  51  52  53
# 18  54  55  56
# 19  57  58  59
# [20 rows x 3 columns]

如果將其設(shè)置為“None”,則將顯示所有行而不省略。

pd.options.display.max_rows = None

最大顯示列數(shù):display.max_columns

顯示列的最大數(shù)量通過display.max_columns 設(shè)置。如果列數(shù)超過display.max_columns的值,則省略中間部分,顯示開頭和結(jié)尾。 默認(rèn)為20,如果設(shè)置為None,則將顯示所有列,不會(huì)被省略。

print(pd.options.display.max_columns)
# 20df_wide = pd.DataFrame(np.arange(90).reshape((3, 30)))print(df_wide)
#    0   1   2   3   4   5   6   7   8   9  ...  20  21  22  23  24  25  26  27  \
# 0   0   1   2   3   4   5   6   7   8   9 ...  20  21  22  23  24  25  26  27   
# 1  30  31  32  33  34  35  36  37  38  39 ...  50  51  52  53  54  55  56  57   
# 2  60  61  62  63  64  65  66  67  68  69 ...  80  81  82  83  84  85  86  87   
#    28  29  
# 0  28  29  
# 1  58  59  
# 2  88  89  
# [3 rows x 30 columns]pd.options.display.max_columns = 10print(df_wide)
#    0   1   2   3   4  ...  25  26  27  28  29
# 0   0   1   2   3   4 ...  25  26  27  28  29
# 1  30  31  32  33  34 ...  55  56  57  58  59
# 2  60  61  62  63  64 ...  85  86  87  88  89
# [3 rows x 30 columns]pd.options.display.max_columns = Noneprint(df_wide)
#    0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  \
# 0   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18   
# 1  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48   
# 2  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78   
#    19  20  21  22  23  24  25  26  27  28  29  
# 0  19  20  21  22  23  24  25  26  27  28  29  
# 1  49  50  51  52  53  54  55  56  57  58  59  
# 2  79  80  81  82  83  84  85  86  87  88  89  

整體顯示寬度通過display.width設(shè)置。見下文。 另外,在終端中運(yùn)行時(shí),display.max_columns 的默認(rèn)值為 0,并且根據(jù)終端的寬度自動(dòng)省略。

默認(rèn)顯示的行數(shù)和列數(shù):display.show_dimensions

與前面的示例一樣,如果省略了行和列,則行數(shù)和列數(shù)將顯示在末尾,例如[3 行 x 30 列]。 可以使用 display.show_dimensions 配置此行為。默認(rèn)為“truncate”,只有省略時(shí)才會(huì)顯示行數(shù)和列數(shù)。

print(pd.options.display.show_dimensions)
# truncatepd.options.display.max_columns = 10print(df_wide)
#    0   1   2   3   4  ...  25  26  27  28  29
# 0   0   1   2   3   4 ...  25  26  27  28  29
# 1  30  31  32  33  34 ...  55  56  57  58  59
# 2  60  61  62  63  64 ...  85  86  87  88  89
# [3 rows x 30 columns]df = pd.DataFrame(np.arange(12).reshape((3, 4)))print(df)
#    0  1   2   3
# 0  0  1   2   3
# 1  4  5   6   7
# 2  8  9  10  11

如果設(shè)置為True,則無論是否省略都會(huì)始終顯示,如果設(shè)置為False,則始終隱藏。

pd.options.display.show_dimensions = Trueprint(df_wide)
#    0   1   2   3   4  ...  25  26  27  28  29
# 0   0   1   2   3   4 ...  25  26  27  28  29
# 1  30  31  32  33  34 ...  55  56  57  58  59
# 2  60  61  62  63  64 ...  85  86  87  88  89
# [3 rows x 30 columns]print(df)
#    0  1   2   3
# 0  0  1   2   3
# 1  4  5   6   7
# 2  8  9  10  11
# [3 rows x 4 columns]pd.options.display.show_dimensions = Falseprint(df_wide)
#    0   1   2   3   4  ...  25  26  27  28  29
# 0   0   1   2   3   4 ...  25  26  27  28  29
# 1  30  31  32  33  34 ...  55  56  57  58  59
# 2  60  61  62  63  64 ...  85  86  87  88  89print(df)
#    0  1   2   3
# 0  0  1   2   3
# 1  4  5   6   7
# 2  8  9  10  11

總體最大顯示寬度:display.width

總體最大顯示寬度通過display.width 設(shè)置。 默認(rèn)值為 80。如果超過該值,就會(huì)發(fā)生換行。換行符處顯示反斜杠 \,如下例所示。 即使display.width為None,也不會(huì)顯示整個(gè)圖像。

print(pd.options.display.width)
# 80pd.options.display.max_columns = Noneprint(df_wide)
#    0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  \
# 0   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18   
# 1  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48   
# 2  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78   
#    19  20  21  22  23  24  25  26  27  28  29  
# 0  19  20  21  22  23  24  25  26  27  28  29  
# 1  49  50  51  52  53  54  55  56  57  58  59  
# 2  79  80  81  82  83  84  85  86  87  88  89  pd.options.display.width = 60print(df_wide)
#    0   1   2   3   4   5   6   7   8   9   10  11  12  13  \
# 0   0   1   2   3   4   5   6   7   8   9  10  11  12  13   
# 1  30  31  32  33  34  35  36  37  38  39  40  41  42  43   
# 2  60  61  62  63  64  65  66  67  68  69  70  71  72  73   
#    14  15  16  17  18  19  20  21  22  23  24  25  26  27  \
# 0  14  15  16  17  18  19  20  21  22  23  24  25  26  27   
# 1  44  45  46  47  48  49  50  51  52  53  54  55  56  57   
# 2  74  75  76  77  78  79  80  81  82  83  84  85  86  87   
#    28  29  
# 0  28  29  
# 1  58  59  
# 2  88  89  pd.options.display.width = Noneprint(df_wide)
#    0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  \
# 0   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18   
# 1  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48   
# 2  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78   
#    19  20  21  22  23  24  25  26  27  28  29  
# 0  19  20  21  22  23  24  25  26  27  28  29  
# 1  49  50  51  52  53  54  55  56  57  58  59  
# 2  79  80  81  82  83  84  85  86  87  88  89  

每列最大顯示寬度:display.max_colwidth

每列的最大顯示寬度通過display.max_colwidth 設(shè)置。 默認(rèn)值為 50。

print(pd.options.display.max_colwidth)
# 50df_long_col = pd.DataFrame({'col': ['a' * 10, 'a' * 30, 'a' * 60]})print(df_long_col)
#                                                  col
# 0                                         aaaaaaaaaa
# 1                     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# 2  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...pd.options.display.max_colwidth = 80print(df_long_col)
#                                                             col
# 0                                                    aaaaaaaaaa
# 1                                aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# 2  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

每一列都被省略以適應(yīng) display.max_colwidth 設(shè)置。

df_long_col2 = pd.DataFrame({'col1': ['a' * 10, 'a' * 30, 'a' * 60],'col2': ['a' * 10, 'a' * 30, 'a' * 60]})pd.options.display.max_colwidth = 20print(df_long_col2)
#                   col1                 col2
# 0           aaaaaaaaaa           aaaaaaaaaa
# 1  aaaaaaaaaaaaaaaa...  aaaaaaaaaaaaaaaa...
# 2  aaaaaaaaaaaaaaaa...  aaaaaaaaaaaaaaaa...

列名columns不受display.max_colwidth的影響,不能省略。

df_long_col_header = pd.DataFrame({'a' * 60: ['a' * 10, 'a' * 30, 'a' * 60]})pd.options.display.max_colwidth = 40print(df_long_col_header)
#   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# 0                               aaaaaaaaaa                    
# 1           aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa                    
# 2  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...                 

列名顯示的右對(duì)齊/左對(duì)齊:display.colheader_justify

列名顯示的右對(duì)齊或左對(duì)齊通過d??isplay.colheader_justify 設(shè)置。 默認(rèn)為“right”。如果要將其左對(duì)齊,請(qǐng)使用“l(fā)eft”。

print(pd.options.display.colheader_justify)
# rightprint(df_long_col)
#                                        col
# 0                               aaaaaaaaaa
# 1           aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# 2  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...pd.options.display.colheader_justify = 'left'print(df_long_col)
#   col                                     
# 0                               aaaaaaaaaa
# 1           aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
# 2  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
http://www.risenshineclean.com/news/35547.html

相關(guān)文章:

  • 濟(jì)寧網(wǎng)站建設(shè)優(yōu)化百度網(wǎng)盤登錄入口 網(wǎng)頁
  • 把html文件生成網(wǎng)址平原縣網(wǎng)站seo優(yōu)化排名
  • 網(wǎng)頁設(shè)計(jì)實(shí)訓(xùn)總結(jié)2500字seo網(wǎng)站推廣案例
  • 諸城營銷型網(wǎng)站建設(shè)seo自動(dòng)優(yōu)化工具
  • 中國空間站科幻作文1000字中國突然宣布一重磅消息
  • 網(wǎng)頁設(shè)計(jì)與網(wǎng)站建設(shè)作業(yè)怎么做周口seo公司
  • 東莞專業(yè)做網(wǎng)站建設(shè)服務(wù)怎么做百度推廣運(yùn)營
  • 46設(shè)計(jì)網(wǎng)站官網(wǎng)快速開發(fā)網(wǎng)站的應(yīng)用程序
  • 手機(jī)怎么在百度做網(wǎng)站百度seo軟件優(yōu)化
  • 獨(dú)立ip做網(wǎng)站廣告聯(lián)盟app推廣
  • 做房產(chǎn)應(yīng)看的網(wǎng)站下載微信
  • lamp 搭建wordpressseo外鏈工具有用嗎
  • 怎么推廣網(wǎng)站建設(shè)業(yè)務(wù)百度醫(yī)生
  • 做網(wǎng)站都有什么項(xiàng)目網(wǎng)絡(luò)營銷推廣要求
  • 建設(shè)公司營銷網(wǎng)站優(yōu)化落實(shí)新十條措施
  • 屬于網(wǎng)站的管理 更新 維護(hù)微信營銷軟件手機(jī)版
  • 網(wǎng)站專題頁怎么做百度收錄關(guān)鍵詞
  • 中鐵三局招聘信息2022關(guān)鍵詞seo優(yōu)化公司
  • html5做網(wǎng)站鏈接范例網(wǎng)站推廣100種方法
  • 中國建設(shè)銀行安徽分行網(wǎng)站推廣什么軟件可以長(zhǎng)期賺錢
  • 珍島信息技術(shù)有限公司做網(wǎng)站服務(wù)網(wǎng)上營銷方式和方法
  • 直播網(wǎng)站開發(fā)核心技術(shù)如何做營銷策劃方案
  • 小企業(yè)網(wǎng)站建設(shè)怎樣網(wǎng)絡(luò)優(yōu)化工程師騙局
  • 上傳網(wǎng)站的三種方法網(wǎng)絡(luò)營銷工程師
  • 做網(wǎng)站申請(qǐng)什么商標(biāo)seo咨詢服務(wù)價(jià)格
  • 小說網(wǎng)站虛擬主機(jī)網(wǎng)絡(luò)促銷
  • 建一個(gè)類似b站的網(wǎng)站多少錢百度用戶服務(wù)中心官網(wǎng)電話
  • 做搞笑視頻網(wǎng)站靠神魔賺錢好的競(jìng)價(jià)推廣外包公司
  • 2018網(wǎng)站外鏈怎么做谷歌seo顧問
  • 棗莊網(wǎng)站設(shè)計(jì)淘寶指數(shù)在線查詢