日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

Python 打印行列控制(API:pandas.set_option())

發(fā)布時間:2023/11/27 生活经验 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python 打印行列控制(API:pandas.set_option()) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

目錄

pandas.set_option():控制打印的行列

使用方式

實戰(zhàn)

1、讀取數(shù)據(jù),發(fā)現(xiàn)問題

2、顯示行列

總代碼

參考資料:


pandas.set_option():控制打印的行列

參數(shù)介紹:

compute.[use_bottleneck, use_numexpr]
display.[chop_threshold, colheader_justify, column_space, date_dayfirst, date_yearfirst, encoding, expand_frame_repr, float_format]
display.html.[border, table_schema, use_mathjax]
display.[large_repr]
display.latex.[escape, longtable, multicolumn, multicolumn_format, multirow, repr]
display.[max_categories, max_columns, max_colwidth, max_info_columns, max_info_rows, max_rows, max_seq_items, memory_usage, min_rows, multi_sparse, notebook_repr_html, pprint_nest_depth, precision, show_dimensions]
display.unicode.[ambiguous_as_wide, east_asian_width]
display.[width]
io.excel.ods.[reader]
io.excel.xls.[reader, writer]
io.excel.xlsb.[reader]
io.excel.xlsm.[reader, writer]
io.excel.xlsx.[reader, writer]
io.hdf.[default_format, dropna_table]
io.parquet.[engine]
mode.[chained_assignment, sim_interactive, use_inf_as_na, use_inf_as_null]
plotting.[backend]
plotting.matplotlib.[register_converters]

使用方式

# 設置最大列數(shù)
# pd.set_option('display.max_columns',1000)
# 設置最大行數(shù)
# pd.set_option('display.max_rows',1000)
# 設置寬度
# pd.set_option('display.width', 1000)
# 設置最大列寬
# pd.set_option('display.max_colwidth',1000)

實戰(zhàn)

1、讀取數(shù)據(jù),發(fā)現(xiàn)問題

import pandas as pd
import numpy as np# 1、讀取數(shù)據(jù)
column_name=['Sample code number','Clump Thickness','Uniformity of Cell Size','Uniformity of Cell Shape','Marginal Adhesion','Single Epithelial Cell Size','Bare Nuclei','Bland Chromatin','Normal Nucleoli','Mitoses','Class']
data=pd.read_csv('breast-cancer-wisconsin.data', names=column_name)
print(data)

可以看出,行和列都有很多的隱藏,使得看不到全部的數(shù)據(jù),而原文件打開也不方便,因此想辦法讓它的行和列都可以顯示出來。

2、顯示行列

# 設置最大列數(shù)
pd.set_option('display.max_columns',1000)
# 設置最大行數(shù)
pd.set_option('display.max_rows',1000)

問題解決,可以成功顯示出行和列了。

下載測試數(shù)據(jù)的網(wǎng)站:https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/breast-cancer-wisconsin.data

總代碼

# 行列顯示
import pandas as pd
import numpy as np# 1、讀取數(shù)據(jù)
column_name=['Sample code number','Clump Thickness','Uniformity of Cell Size','Uniformity of Cell Shape','Marginal Adhesion','Single Epithelial Cell Size','Bare Nuclei','Bland Chromatin','Normal Nucleoli','Mitoses','Class']# 設置最大列數(shù)
pd.set_option('display.max_columns',1000)
# 設置最大行數(shù)
pd.set_option('display.max_rows',1000)
# 設置寬度
# pd.set_option('display.width', 1000)
# 設置最大列寬
# pd.set_option('display.max_colwidth',1000)data=pd.read_csv('breast-cancer-wisconsin.data', names=column_name)
print(data)

參考資料:

Pycharm控制臺輸出結果“部分內(nèi)容省略”的解決方法_fly_Xiaoma的博客-CSDN博客

python pandas.set_option()詳解_lvchunyang66的博客-CSDN博客_pandas set_option

總結

以上是生活随笔為你收集整理的Python 打印行列控制(API:pandas.set_option())的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。