首先,需要确保已安装了 pandas 库。可以使用以下命令安装:

pip install pandas

然后,可以使用以下代码使用 pandas 库读取 Excel 表格数据并分别提取第一列、第二列和第三列:

import pandas as pd

# 读取 Excel 表格数据
df = pd.read_excel('文件路径/文件名.xlsx')

# 去除 index 索引
df = df.reset_index(drop=True)

# 分别提取第一列、第二列和第三列
column1 = df.iloc[:, 0]
column2 = df.iloc[:, 1]
column3 = df.iloc[:, 2]

需要将文件路径/文件名.xlsx替换为实际的 Excel 文件路径和文件名。

现在,column1column2column3 变量分别包含了 Excel 表格的第一列、第二列和第三列数据。


原文地址: https://www.cveoy.top/t/topic/pF1l 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录