question:
When doing program migration today, the original OK program suddenly reported an error, and finally found out that it was a problem when pandas read the file: when using pd.readcsv to read the file in this environment, it will automatically change the first column into an index, resulting in The overall data is offset, and the last column of data is all empty.
reason:
I made a comparison with the previous environment and found that the original pandas is version 1.3.5, while the pandas in the new environment is version 1.3.4. I
guessed the problem of the default value of the index column parameters in version 1.3.4, so I went to see the two versions The source code:
the default value is actually the same! ! ! How can this work?
As a result, after reading the whole article, I don’t know how the parameters here are affected. Only the usage of the parameters is explained here. Fortunately, the usage is explained here, and the problem can be solved directly according to the usage:
Solution:
Set parameter index_col to false
df0 = pd.read_csv(region_path, index_col=False)