Advertisement
Guest User

Untitled

a guest
Oct 11th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. import pandas as pd
  2. import folium
  3. from folium.plugins import HeatMap
  4.  
  5. content = pd.ExcelFile('export_content.xlsx')
  6. top_hashtags_tab = pd.read_excel(content, 'Top Hashtags')
  7.  
  8. dashboard = pd.ExcelFile('export_dashboard.xlsx')
  9. stream_tab = pd.read_excel(dashboard, 'Stream')
  10. stream_tab = stream_tab[['Tweet content', 'Latitude', 'Longitude']]
  11.  
  12.  
  13. def fill_map(map, hashtags_list):
  14.     for hashtag in hashtags_list:
  15.         rows_with_hashtag = stream_tab[stream_tab['Tweet content'].str.contains('#' + hashtag)]
  16.         hashtag_places = [[row['Latitude'],row['Longitude']] for index, row in rows_with_hashtag.iterrows()]
  17.         HeatMap(hashtag_places).add_to(map)
  18.  
  19.  
  20. hashtags_list = top_hashtags_tab['Hash']
  21. map = folium.Map(location=[51.5074, 0.1278], zoom_start = 1)
  22.  
  23. fill_map(map, hashtags_list)
  24. map.save('map.html')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement