csv将纬度列导入为float需要将其数字化

问题描述

导入csv文件后,我使用streamlit对其进行了绘制。

问题是为纬度/经度导入的列类型为浮点型。如何将这种浮动形式转换为可读格式?

我使用pd.tu_numeric()或.apply(np.int64)尝试了一些技巧,但没有任何效果

new_df['latitude'] = data['latitude'].dropna().apply(np.int64)
new_df['longitude'] = data['longitude'].dropna().apply(np.int64)


pd.to_numeric(data,errors='coerce')
st.map(data)

感谢帮助初学者

解决方法

尝试使用以下代码段

new_df['latitude']=pd.to_numeric(new_df['latitude']) 
new_df['longitude']=pd.to_numeric(new_df['longitude])

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_numeric.html