Formatting float number in list

-1

I have a dataframe with columns of Latitude and Longitude, in the format string

Atibaia['LATITUDE'].head()

140     -231,124,852,387,647
245     -231,159,749,902,692
254          -23,116,747,205
512     -231,560,912,572,211
1348         -23,115,763,607

I have already been able to remove the commas and convert to float using the following code snippet:

Atibaia['LATITUDE'] = Atibaia.loc[:,'LATITUDE'].str.replace(',','').astype(float)
Atibaia['LONGITUDE'] = Atibaia.loc[:,'LONGITUDE'].str.replace(',','').astype(float)

(It even generates the following warning: C: \ Users \ Ramon \ Anaconda3 \ lib \ site-packages \ ipykernel_launcher.py: 2: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc [row_indexer, col_indexer] = value instead

See the caveats in the documentation: link )

but it works and I end this result:

Atibaia['LATITUDE'].head()

140    -2.311249e+14
245    -2.311597e+14
254    -2.311675e+10
512    -2.315609e+14
1348   -2.311576e+10

In the meantime I need the values in this format - > -23.1171, -46.5502 (Latitude x Longitude of Atibaia)

How do I proceed now? There is a week that I'm 'stuck' in this and I do not find a way around the situation. "     

asked by anonymous 30.03.2018 / 04:06

1 answer

0

After a few days I found an answer, as follows:

Atibaia['LATITUDE'] = atibaia.LATITUDE.str.replace(',','')
Atibaia['LATITUDE'] = atibaia['LATITUDE'].apply(pd.to_numeric) # <--- THIS!!!!!!
Atibaia['LATITUDE'].head()
    
12.04.2018 / 07:11