convert pandas Series with large integer strings and Nones to nullable Int64 without precision loss

Viewed 72

I have a pandas Series with large integers as strings and Nones, and want to convert this to pandas Int64 (nullable integer) without precision loss. Casting to float (what e.g. pd.to_numeric does) leads to precision loss. What is a good way to do that?

E.g.

test_series = pd.Series(['4498465375688747025',
'4366843671738038466',
None,
None,
'4235221967816327545'])

test_series.astype('Int64') throws TypeError: object cannot be converted to an IntegerDtype on pandas 1.0.5

0 Answers
Related