pandas read_csv parse header as string type but i want integer
问题 for example, csv file is as below ,(1,2,3) is header! 1,2,3 0,0,0 I read csv file using pd.read_csv and print import pandas as pd df = pd.read_csv('./test.csv') print(df[1]) it occur error key error:1 it seems like that read_csv parse header as string.. is there any way using integer type in dataframe column? 回答1: I think more general is cast to columns names to integer by astype: df = pd.read_csv('./test.csv') df.columns = df.columns.astype(int) Another way is first get only first column and