我已经在 python 中导入了一个 excel 文件,我正在尝试将第 7 行作为起始列。我需要隐藏前 6 行我该怎么做? [复制]

Posted

技术标签:

【中文标题】我已经在 python 中导入了一个 excel 文件,我正在尝试将第 7 行作为起始列。我需要隐藏前 6 行我该怎么做? [复制]【英文标题】:I have imported an excel file in python and I am trying to make the 7th ROW the starting Columns. I need to hide the first 6 rowsHow can i do that? [duplicate] 【发布时间】:2021-08-27 13:25:39 【问题描述】:

我已经在 python 中导入了一个 excel 文件,我正在尝试将第 7 行作为起始列。我需要隐藏前 6 行。我该怎么做?

import pandas as pd
df = pd.read_excel('C:/Users/sfreeman/Desktop/userexport.xls')
df

【问题讨论】:

你检查read_excel的参数了吗? 【参考方案1】:
import pandas as pd
df = pd.read_excel('C:/Users/sfreeman/Desktop/userexport.xls', skiprows=6)
display(df)

【讨论】:

如果这可以是我的第一个正确答案就好了:-) 最后df在那里做什么? @Outserved 如果此答案解决了您的问题,请考虑接受。 嗨@Dominique,你也可以运行df而不是display(df)来显示数据框【参考方案2】:
import pandas as pd
df = pd.read_excel('C:/Users/sfreeman/Desktop/userexport.xls', skiprows=range(7))
df.head()

然后:

df.transpose()

使列成为行,反之亦然。

【讨论】:

以上是关于我已经在 python 中导入了一个 excel 文件,我正在尝试将第 7 行作为起始列。我需要隐藏前 6 行我该怎么做? [复制]的主要内容,如果未能解决你的问题,请参考以下文章

在python中导入excel文件并识别内容被删除的单元格

由于在现有项目中导入了特定的库,因此无法在 Eclipse 中解决导入问题

在 R 中导入 excel 表头

如何在 Python 中导入 Excel 文件列并找到它们之间的相关系数?

python 使用Mac在Pandas(Python)中导入Excel文件

在 HTML 文件中导出 PHP 表