Python Folium:类型为'的TypeError对象;数据帧';JSON不可序列化

Python Folium:类型为'的TypeError对象;数据帧';JSON不可序列化,python,pandas,folium,Python,Pandas,Folium,我使用的是一个简单的.csv,如下所示: Latitude,Longitude,Count,Zero 49.978728,11.949353,100,0 49.978728,11.950353,2,0 之后,我将其转换为熊猫数据帧: 作为pd进口熊猫 进口叶 将numpy作为np导入 data = pd.read_csv("farmers_location.csv") #extract value from data count = data.loc[:, ["Count"]] la

我使用的是一个简单的.csv,如下所示:

Latitude,Longitude,Count,Zero
49.978728,11.949353,100,0
49.978728,11.950353,2,0
之后,我将其转换为熊猫数据帧:

作为pd进口熊猫 进口叶 将numpy作为np导入

 data = pd.read_csv("farmers_location.csv")

 #extract value from data
 count = data.loc[:, ["Count"]]
 latitude = data.loc[:, ["Latitude"]]
 longitude = data.loc[:, ["Longitude"]]

 #df_counters = pd.DataFrame(count,latitude,longitude)
 df_counters = count.join(latitude).join(longitude)
 df_counters.head()

 # forcely convert the numpy.int64 into string 
 df_counters['Count'] = df_counters['Count'].astype(str)


 locations = df_counters[['Latitude', 'Longitude']]
 locationlist = locations.values.tolist()
 len(locationlist)
 locationlist[1]
之后,我绘制了一张地图:

map = folium.Map(location=[49.978, 11.950], zoom_start=20)
for point in range(0, len(locationlist)):
     folium.Marker(locationlist[point], popup=df_counters['Count'] 
     [point]).add_to(map)
这很好,但是如果我将最后三行替换为:

 map = folium.Map(location=[49.978, 11.950], zoom_start=12)
 for point in range(0, len(locationlist)):
      radius = count/20
      color1 = "#0A8A9F"
      color2= "#E37222"
      color= np.where(count>99, color1, color2)
      folium.CircleMarker(locationlist[point],
                          radius=radius,
                          color=color,
                          fill=True).add_to(map)
我最终出现以下错误:

TypeError:类型为“DataFrame”的对象不可JSON序列化

编辑:因为我解决了这个问题,这里有两个解决方案:

可以通过str(颜色)和str(半径)将颜色和半径转换为字符串