Closed CorBer closed 5 years ago
Hi @CorBer ,
This is a pretty interesting bug, thanks for reporting. The reason is actually the code line df = df[1:] #take the data less the header row
, because in this case the first index has value 1. When saving and loading the csv, it resets the index to 0, so everything works fine.
I fixed the error for the next release, however you can easily avoid this by just using the awesome pd.read_csv functionality, which can also read from a web server like this:
import pandas as pd
import pandas_bokeh
pandas_bokeh.output_notebook()
df = pd.read_csv(r'http://www.seismicportal.eu/fdsnws/event/1/query?limit=100&minmag=4.5&minlat=34&maxlat=42&minlon=26&maxlon=46&format=text', sep="|")
df.columns=df.columns.str.strip()
df.Longitude=df.Longitude.astype(float)
df.Latitude=df.Latitude.astype(float)
df.Magnitude=df.Magnitude.astype(float)
df.head()
df['size']=df.Magnitude*5
df.plot_bokeh.map(
x="Longitude",
y="Latitude",
category='Magnitude',
colormap='Magma',
line_color='black',
hovertool_string="<h2> @{Time} </h2> <h3> Magnitude: @{Magnitude} </h3>",
tile_provider='CARTODBPOSITRON',
size="size",
figsize=(1200, 800),
title="earthquakes")
I hope this answers you question.
Best Patrik
Hi Patrik,
Ive just tested and it works. Its a win for both of us that way, I have learned a better way to read the data and you got a bug that you could remove ;) Thanks for the fast reaction and keeping this library updated.
regards Cor
I am still amazed by the power libraries like yours bring forward. Being able to question a webserver and presenting its results on a map in just a few lines is great ! Just realized that the astype(float) transformations are not necessary also.
Hi,
I am using the latest version of the library in a JupyterLab (1.1.4) environment.
The problem I have that I want to plot a rather simple dataset I retrieve from a url. The data is retrieved and converted to a pandas DataFrame without problems. If I then try to plot the data the library simply turns out error "0".
The full standalone code is below. Notice that nearly at the end I save the pandas dataframe to a CSV, then directly read that CSV back into another pandas dataframe and I can plot the data. So plotting df_a works as planned, trying to plot df results in an error.
regards Cor