【发布时间】:2026-02-21 06:45:01
【问题描述】:
lat long time
0 39.991861 116.344372 2.823611
1 39.979768 116.310597 22.263056
2 31.235001 121.470624 13.141667
3 31.248822 121.460637 1.805278
上面是一个数据框rep_points。当我运行下面的代码时,它给出了一个错误
Type error: cannot convert the series to <class 'float'>
在画圈的那一行。
gmap = gmplot.GoogleMapPlotter(rep_points['lat'][0], rep_points['long'][0], 11)
gmap.plot(df_min.lat, df_min.lng)
gmap.scatter(rep_points['lat'],rep_points['long'],c='aquamarine')
gmap.circle(rep_points['lat'],rep_points['long'], 100, color='yellow')
gmap.draw("user001_clus_time.html")
我应该如何解决这个错误?我试过使用
rep_pints['lat'].astype(float)
和
rep_pints['long'].astype(float)
但是效果不好
【问题讨论】:
-
所以
rep_points = rep_points.apply(pd.to_numeric, errors='coerce')或rep_points = rep_points.apply(pd.to_numeric, errors='coerce').dropna()用于删除缺失值的行(通过转换非数值创建)应该可以工作 -
@jezrael 这甚至不是同一个错误。我不确定这会有所帮助
-
@iam.Carrot - 好的,所以重新打开了。
标签: python python-3.x pandas google-maps