在Pycharm中使用Pandas時輸出結果中列被省略的解決辦法
阿新 • • 發佈:2019-02-28
文件 設置 。。 tco wide post tor 表示 RoCE
在使用pycharm學習pandas的過程中我發現好多時候會發生不能輸出所有列的情況,上網搜了一下,發現解決的辦法是使用一個輸出控制的函數。
在下面的代碼中我們只是輸出starbucks_store_worldwide.csv
這個文件的第一行,想看一下各列的標簽都會被省略。。。
# coding=utf-8
import pandas as pd
import numpy as np
file_path = "./starbucks_store_worldwide.csv"
df = pd.read_csv(file_path)
print(df.head(1))
輸出的結果如下:
Brand Store Number ... Longitude Latitude
0 Starbucks 47370-257954 ... 1.53 42.51
[1 rows x 13 columns]
Process finished with exit code 0
可以看到一共有13列,卻只輸出了4列,解決辦法如下:
# coding=utf-8 import pandas as pd import numpy as np file_path = "./starbucks_store_worldwide.csv" # 在這裏添加一個控制最大輸出列數的函數 pd.set_option('display.max_columns',None) df = pd.read_csv(file_path) print(df.head(1))
輸出結果如下:
Brand Store Number Store Name Ownership Type Street Address 0 Starbucks 47370-257954 Meritxell, 96 Licensed Av. Meritxell, 96 City State/Province Country Postcode Phone Number 0 Andorra la Vella 7 AD AD500 376818720 Timezone Longitude Latitude 0 GMT+1:00 Europe/Andorra 1.53 42.51 Process finished with exit code 0
相應的,如果行被省略,可以添加如下控制函數:
pd.set_option(‘display.max_rows‘,1000)
1000是要顯示的行數,可以自行設置,當設置為None
時,表示不省略
在Pycharm中使用Pandas時輸出結果中列被省略的解決辦法