我在尝试使用 Python 将定价数据绘制到地图上时遇到问题。我的数据只有几列:LONGITUDE LATITUDE PRICE 和 LONG/LAT 都是 float64,而 PRICE 是 int64。知道是什么原因导致无法绘制吗?
以下示例数据
代码:
import pandas as pd
import folium
from folium.plugins import HeatMap
final = xxx.xlsx
heat1 = r"C:\Users\xx\Python\Price Tracking\Real Estate\Database\heatmap_price.html"
for_map = pd.read_excel(final, sheet_name = 'Sheet1').fillna(0)
max_amount = float(for_map['PRICE'].max())
hmap = folium.Map(location=[42.5, -75.5], zoom_start=7, )
hm_wide = HeatMap( list(zip(for_map.LATITUDE.values, for_map.LONGITUDE.values, for_map.PRICE.values)),
min_opacity=0.2,
max_val=max_amount,
radius=17, blur=15,
max_zoom=1,
)
print(for_map.dtypes)
hmap.add_child(hm_wide)
hmap.save(heat1)
错误:
TypeError: Object of type int64 is not JSON serializable