# CrossCompute
ready_table_path = 'Table with average monthly savings(within 0.5 Mile) and tree count(within 0.5 Mile).csv'
target_folder = '/tmp'
import pandas as pd
# import libraries
import subprocess
subprocess.call('pip install folium'.split())
import folium
ready_table = pd.read_csv(ready_table_path)
ready_table.head()
len(ready_table)
ready_table.drop(ready_table.columns[[0,1]], axis=1, inplace=True)
ready_table.head()
#ready_table = ready_table[['Longitude','Latitude','Total Tree Count within 0.5 Mile','Periodic Savings within 0.5 Mile']]
#ready_table=ready_table
len(ready_table)
len(ready_table)
# Make a data frame with dots to show on the map
# data = pd.DataFrame({
# 'lat':[-58, 2, 145, 30.32, -4.03, -73.57, 36.82, -38.5],
# 'lon':[-34, 49, -38, 59.93, 5.33, 45.52, -1.29, -12.97],
# 'name':['Buenos Aires', 'Paris', 'melbourne', 'St Petersbourg', 'Abidjan', 'Montreal', 'Nairobi', 'Salvador']
# })
# data
# Make an empty map
m = folium.Map(location=[20, 0], tiles="Mapbox Bright", zoom_start=2)
# I can add marker one by one on the map
for i in range(0,len(ready_table)):
folium.Marker([ready_table.iloc[i]['Longitude'], ready_table.iloc[i]['Latitude']], popup=ready_table.iloc[i]['Total Tree Count within 0.5 Mile']).add_to(m)
m.save('312_markers_on_folium_map1.html')
ready_geotable = ready_table.copy() # Prevent SettingwithCopyWarning
# Set radius for each point
# The bigger the circle, the more the company saved
ready_geotable['RadiusInPixelsRange5-50'] = ready_geotable['Periodic Savings']
# Set color for each point using a gradient
# The darker the color, the more trees the company is surrounded by
ready_geotable['FillRedsFromMean'] = ready_geotable['Total Tree Count within 0.5 Mile']
Hypothesis:<br>
# See what we did
ready_geotable[:3]
# Save file to target folder to include it in the result download
target_path = target_folder + '/b.csv'
ready_geotable.to_csv(target_path, index=False)
print(f'b_geotable_path = {target_path}') # Print geotable_path to render map
# %matplotlib inline
# axes = address_table[[
# 'Tree Count Within 100 Meters',
# 'Predicted Graduation Rate',
# ]].plot(kind='bar')
# # Save file to target folder to include it in the result download
# target_path = target_folder + '/c.png'
# figure = axes.get_figure()
# figure.savefig(target_path)
# print(f'c_image_path = {target_path}')
YOUR INTERPRETATION OF THE RESULTS
{a_table : YOUR TABLE NAME ? YOUR TABLE DESCRIPTION}
{b_geotable : YOUR MAP NAME ? YOUR MAP DESCRIPTION}
{c_image : YOUR PLOT NAME ? YOUR PLOT DESCRIPTION}