I have a column with values in floats and I want to turn them into ints.
pdsm:
federation_unit_id city_id
id
3 8.0 3.0
7 None None
17 8.0 3.0
18 8.0 3.0
19 8.0 9.0
Their types are of values in the columns are: class 'float', except by None that is a NoneType.
If I try this:
pdsm['federation_unit_id']=pdsm['federation_unit_id'].astype(int)
pdsm['city_id'].iloc[0]=pdsm.city_id.astype(int)
I get this:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
If I try this:
pdsm['federation_unit_id']=pdsm['federation_unit_id'].apply(lambda x: x.astype(int) if x is not None else None)
pdsm['city_id'].iloc[0]=pdsm.city_id.apply(lambda x: x.astype(int) if x is not None else None)
I get:
AttributeError: 'float' object has no attribute 'astype'
Can anyone help? I'm going nuts here.