I need to remove the .0s after floats
in a column of a DataFrame
, made from a dictionary
.
For example, the dictionary
might be:
mydict = { "part1" : [1,2,None,4,5] "part2" : [6,7,None,9,10] }
and then when I mydf = pd.DataFrame(mydict)
, the DataFrame
generated is as follows:
part1 part2
0 1.0 6.0
1 2.0 7.0
2 NaN NaN
3 4.0 9.0
4 5.0 10.0
This happens because every single column in a DataFrame
must have all objects of the same type. But, I want to have no .0s at the end of my data for look purposes. Obviously, I can't make them integers, due to the lack of an NaN
in integers. I also can't make them strings, for the reason of numerical sorting. I also wouldn't want "01","02","03"…"10"
for the purpose of looks.
Becuase this project is really serious, the looks matter, so please don't blame me of overthinking looks of data.