假设要读取excel文档中第一列的数据,可以使用pandas库中的read_excel函数:

import pandas as pd

# 读取excel文档
df = pd.read_excel('file.xlsx')

# 获取第一列数据
col_data = df.iloc[:, 0].tolist()

# 打印数据
print(col_data)

其中,iloc函数用于获取指定行列的数据,tolist函数用于将获取到的数据转换为列表形式。

iris = datasetsload_irisgt = iristargetdata = irisdata 2怎么替换Python读取excel文档某列数据的代码

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

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