pandas adding .0 when I import from CSV
You have hit the worst pandas wart of all times. But it's 2022, and missing values for integers are finally supported! Check this out. Here is a csv file, with integer column a
that has a missing value:
a,b
1,y
2,m
,c
3,a
If you read it in a default manner you get the annoying conversion to float:
pd.read_csv('test.csv'):
a b
--------------
0 1.0 y
1 2.0 m
2 NaN c
3 3.0 a
But, if you tell pandas that you want new experimental integers with missing values, you get the good stuff:
pd.read_csv('test.csv', dtype={'a': 'Int64'}):
a b
---------
0 1 y
1 2 m
2 <NA> c
3 3 a