iris = datasetsload_irisgt = iristargetdata = irisdata 2替换成读取excel文档中某列数据
假设要读取excel文档中第一列数据,可以使用pandas库中的read_excel方法:
import pandas as pd
# 读取excel文档
df = pd.read_excel('filename.xlsx')
# 获取第一列数据
data = df.iloc[:, 0].values
其中,iloc[:, 0]表示获取所有行的第一列数据,.values表示将获取到的数据转换为numpy数组。
原文地址: https://www.cveoy.top/t/topic/hhdd 著作权归作者所有。请勿转载和采集!