显示隐藏行后,我读了一个xlsx文件使用python和显示它在linux终端

x6yk4ghg  于 2023-04-20  发布在  Linux
关注(0)|答案(1)|浏览(144)

下面是我的python代码,用于在linux终端中显示xlsx文件的一部分:

import pandas as pd
  2 require_cols=[1,3,6,7,8,9]
  3 df=pd.read_excel('NGXP_6_2_2_dimensions.xlsx',sheet_name='3.1.1 AT&T NBE',usecols=require_cols,skiprows=63,skipfooter=94)
  4 df.dropna(inplace=True)
  5 #df=df.query("Type=='EXF-CTRL'")
  6 #df1=df.head(-96)
  7 print(df)

但是out出现时隐藏了一些部分:

Application Helm  ... Unnamed: 9
0           Type     ...      RAM L
2          EXF-CTRL  ...        4.4
6          EXF-CTRL  ...        0.6
8          EXF-CTRL  ...        2.2
10         EXF-CTRL  ...        0.4
11         EXF-CTRL  ...        8.8
12         EXF-CTRL  ...        2.2
13         EXF-CTRL  ...        4.4
14         EXF-CTRL  ...        4.4
15         EXF-CTRL  ...        8.8
16         EXF-CTRL  ...        1.1
17         EXF-CTRL  ...        8.8
20         EXF-CTRL  ...        0.1
24         EXF-CTRL  ...        2.2
26         EXF-CTRL  ...        2.2
27         EXF-CTRL  ...        8.8
28         EXF-CTRL  ...        2.2
29         EXF-CTRL  ...        4.4
30         EXF-CTRL  ...        4.4
31         EXF-CTRL  ...        2.2
32         EXF-CTRL  ...        0.6
33         EXF-CTRL  ...        8.8
34         EXF-CTRL  ...        4.4
35         EXF-CTRL  ...        2.2
36         EXF-CTRL  ...        4.4
37         EXF-CTRL  ...       17.6
38         EXF-CTRL  ...        4.4

“...”部分是隐藏部分。我怎么能显示整个东西?

import pandas as pd
  2 require_cols=[1,3,6,7,8,9]
  3 df=pd.read_excel('NGXP_6_2_2_dimensions.xlsx',sheet_name='3.1.1 AT&T NBE',usecols=require_cols,skiprows=63,skipfooter=94)
  4 df.dropna(inplace=True)
  5 #df=df.query("Type=='EXF-CTRL'")
  6 #df1=df.head(-96)
  7 print(df)

但是out出现时隐藏了一些部分:

Application Helm  ... Unnamed: 9
0           Type     ...      RAM L
2          EXF-CTRL  ...        4.4
6          EXF-CTRL  ...        0.6
8          EXF-CTRL  ...        2.2
10         EXF-CTRL  ...        0.4
11         EXF-CTRL  ...        8.8
12         EXF-CTRL  ...        2.2
13         EXF-CTRL  ...        4.4
14         EXF-CTRL  ...        4.4
15         EXF-CTRL  ...        8.8
16         EXF-CTRL  ...        1.1
17         EXF-CTRL  ...        8.8
20         EXF-CTRL  ...        0.1
24         EXF-CTRL  ...        2.2
26         EXF-CTRL  ...        2.2
27         EXF-CTRL  ...        8.8
28         EXF-CTRL  ...        2.2
29         EXF-CTRL  ...        4.4
30         EXF-CTRL  ...        4.4
31         EXF-CTRL  ...        2.2
32         EXF-CTRL  ...        0.6
33         EXF-CTRL  ...        8.8
34         EXF-CTRL  ...        4.4
35         EXF-CTRL  ...        2.2
36         EXF-CTRL  ...        4.4
37         EXF-CTRL  ...       17.6
38         EXF-CTRL  ...        4.4

“...”部分是隐藏部分。我怎么能显示整个东西?

gdx19jrr

gdx19jrr1#

很可能你有很多列或者它们的名字太长,所以有些列被隐藏了。你可以使用print (df.columns)打印所有列的名字要显示所有行和列use

pd.set_option('display.max_rows', None)  # print everything rows
pd.set_option('display.max_columns', None)  # print everything columns

或者不选择所有列,例如:

import pandas as pd

df = pd.DataFrame({'a555': [1, 2, 3], 'b555': [1, 2, 3], 'c555': [1, 2, 3], 'd555': [1, 2, 3],
                   'e555': [1, 2, 3], 'f555': [1, 2, 3], 'g555': [1, 2, 3], 'h555': [1, 2, 3],
                   'i555': [1, 2, 3], 'j555': [1, 2, 3], 'k555': [1, 2, 3], 'l555': [1, 2, 3],
                   'm555': [1, 2, 3], 'n555': [1, 2, 3]})

print(df[['a555', 'g555', 'n555']])

相关问题