Summarize the points that you should be careful about when using it for yourself. Will be added sequentially.
When index_col is used when reading CSV, the index type is different from the dtype specification. It seems that it will be decided automatically.
import pandas as pd #Example) input.csv #ID,param1,param2 #0001,01,AAA #0002,02,BBB #0003,10,CCC df = pd.read_csv("input.csv", dtype=object, index_col="ID") #The type is specified as object, but only index becomes int type #The leading 0 is missing
It seems that it is necessary to specify the index later in order to retain the type.
df = pd.read_csv("input.csv", dtype=object) df.set_index("ID", inplace=True) #Now you can keep the original data