Im using Bokeh to plot a pandas Dataframe. Following is the code:
map_options = GMapOptions(lat=19.075984, lng=72.877656, map_type="roadmap", zoom=11)
plot = GMapPlot(x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options)
plot.api_key = "xxxxx"
source = ColumnDataSource(
data=dict(
lat=[float(i) for i in data.lat],
lon=[float(i) for i in data.lon],
size=[int(i)/1000 for i in data['count']],
ID = [i for i in data.merchant_id],
Merchant = [str(i) for i in data.merchant_name],
count = [float(i) for i in data['count']]
)
)
hover = HoverTool(tooltips=[
("(x,y)", "($lat, $lon)"),
("ID", "$ID"),
("Name", "@Merchant"),
("count","$count")
])
# hover.renderers.append(circle_glyph)
plot.tools.append(hover)
circle = Circle(x="lon", y="lat", size='size', fill_color="blue", fill_alpha=0.8, line_color=None)
plot.add_glyph(source, circle)
# plot.add_layout(labels)
plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())
output_file("gmap_plot.html")
show(plot)
In the Hovertool using the "Name" field throws the following error:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 6: unexpected end of data
Also commenting the "Name" field still gives me the error but there is an output plot.
Following is the dataframe I'm using:
lat lon merchant_id count merchant_name
0 18.539971 73.893963 757 777 Portobello
1 18.565766 73.910980 745 10193 The Wok Box
2 18.815427 76.775143 1058 2354 Burrito Factory
3 18.914633 72.817916 87 1985 Flamboyante
4 18.915794 72.824370 94 1116 Butterfly Pond
5 18.916473 72.826868 145 1010 Leo's Boulangerie
6 18.918923 72.828325 115 517 Brijwasi Sweets
7 18.928063 72.832888 973 613 Pandora's Box
8 18.928562 72.832353 101 64 La Folie Patisserie
9 18.929516 72.831860 961 6673 Burma Burma
From my knowledge, the merchant name has characters that's causing the error, but i've tried encoding the column with 'utf-8', 'ascii', etc. But I get the following error:
data['merchant_name'] = data['merchant_name'].str.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 6: ordinal not in range(128)
Any Idea on how to proceed ?