Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import folium
- from folium.plugins import HeatMap
- content = pd.ExcelFile('export_content.xlsx')
- top_hashtags_tab = pd.read_excel(content, 'Top Hashtags')
- dashboard = pd.ExcelFile('export_dashboard.xlsx')
- stream_tab = pd.read_excel(dashboard, 'Stream')
- stream_tab = stream_tab[['Tweet content', 'Latitude', 'Longitude']]
- def fill_map(map, hashtags_list):
- for hashtag in hashtags_list:
- rows_with_hashtag = stream_tab[stream_tab['Tweet content'].str.contains('#' + hashtag)]
- hashtag_places = [[row['Latitude'],row['Longitude']] for index, row in rows_with_hashtag.iterrows()]
- HeatMap(hashtag_places).add_to(map)
- hashtags_list = top_hashtags_tab['Hash']
- map = folium.Map(location=[51.5074, 0.1278], zoom_start = 1)
- fill_map(map, hashtags_list)
- map.save('map.html')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement