I am exporting the data frame below to csv file in Python. The leading 0s are removed in the csv file.
Name ID
0 Bob 0245
1 Tina 2G5B
Both Name and ID values are strings in my pandas df.
I have no problem when re-opening the pandas df in Python with leading 0s after the df is saved by specifying dtype = 'str'
in pd.read_csv
.
However, I would like to open it in R using the read.csv command, the leading 0s will disappear.
If there is a way that I can save the csvs in Python with leading 0s showing up in the csv file. This problem could be solved.
Please advice.
Thanks!