I want to import a csv file into a pandas dataframe. There is a column with IDs, which consist of only numbers, but not every row has an ID.
ID xyz
0 12345 4.56
1 45.60
2 54231 987.00
I want to read this column as String, but even if I specifiy it with
df=pd.read_csv(filename,dtype={'ID': str})
I get
ID xyz
0 '12345.0' 4.56
1 NaN 45.60
2 '54231.0' 987.00
Is there an easy way get the ID as a string without decimal like '12345'without having to edit the Strings after importing the table?
to_csv,to_string), not by changing your underlying data (which looks fine) to awkward types.