How do pandas read specified column names from an Excel…
When using pandas to read an Excel file, you can specify the column names to be read using the usecols parameter.
The following example code demonstrates using the pandas.read_excel() function to read an excel file and specify column names:
import pandas as pd
# 读取excel文件,指定要读取的列名
data = pd.read_excel('file.xlsx', usecols=['列名1', '列名2', '列名3'])
# 打印读取的数据
print(data)
In the example code above, ‘file.xlsx’ is the path of the Excel file to be read, and [‘column1’, ‘column2’, ‘column3’] is the list of column names to be read.