The problem of Pandas read_csv reading one less column

source of the problem

        When using pd.read_csv to read the csv file, it is found that the required data is missing one column, because it does not want the excel file to have a row index, so it will use the data in the first column as the index, and finally pd will display one column less

The solution

        When using pd.read_csv, add a parameter, index_col=False, automatically generate a row index starting with 1, and no longer use the first column as the index

        df = pd.read_csv(self.detail_excel, index_col=False, encoding='gbk')

 

Guess you like

Origin blog.csdn.net/gongzairen/article/details/131006907