0

I'm trying to plot all public parks in my hometown, Santiago. So far I've gathered some relevant info from Google Places and stored it on a webpage for reference:

import pandas as pd
pdf=pd.read_html('http://www.quant.cl/static/HTML/parks.html',index_col=0)[0]

But the classic folium plotting loop fails for an unknown reason:

for did, drow in df.iterrows():
    folium.Marker(location=(drow['lat'],drow['lng']),
                  popup='%s:%s' %(drow['name'],drow['formatted_address'])).add_to(fm)
    fm.save('parques_%d.html' %did)

This generates 51 HTML files (as intended), but I can only visualize them up to parques_21.html, NOT parques_22.html. Could this be due to the accents in the 22nd record?

name                                   O'Higgins Jardín Chino Park
formatted_address    Santiago, Santiago Metropolitan Region, Chile
lat                                                       -33.4692
lng                                                       -70.6606
rating                                                         4.3
Sergio Lucero
  • 862
  • 1
  • 12
  • 21
  • 1
    Got it! It wasn't the accent, it was the Irishman!! It turns out the apostrophe in O'Higgins was derailing the code. – Sergio Lucero Apr 24 '18 at 13:38
  • Glad you found the culprit, and also ended up with a comment that sounds like something from a detective novel :) – Peter Leimbigler Apr 24 '18 at 13:56
  • Thanks Peter, I was a big fan of Clue growing up! You should look up who Bernardo O'Higgins and his father Ambrosio were if you wanna know about our bastard founding father ;) This bug/issue in folium is one I will certainly raise because it also comes up when plotting shared bike systems around the world... – Sergio Lucero Apr 25 '18 at 04:29

1 Answers1

0

Folium will generate HTML that is not proper if some of the data in the pandas DataFrame contains apostrophes or other symbols that will break down the construction.

Sergio Lucero
  • 862
  • 1
  • 12
  • 21