import folium
import pandas as pd
df_bedarf = pd.read_csv('C:/Users/xxxxx/Desktop/xxxxxx/xxxxxxx.csv', sep = ";")
df_bedarf.head()
df_locations = df_bedarf[["Latitude", "Longitude"]]
location_list = df_locations.values.tolist()
location_list_size= len(location_list)
map_points = folium.Map(location = [47.57087, 13.43828], zoom_start = 7)
for point in range(0, location_list_size):
folium.circle(
location = location_list[point],
popup=df_locations["suburb"][point] + ": " + df_locations["Sort"][point],
radius = str(df_locations["t/a"][point]*100)
color="#17cbef",
fill=True,
opacity =0.8,
fill_color="#17cbef,
stroke = True,
weight = 1.0,
).add_to(map_points)
map_points
This is the head():
Unnamed: 0 Suburb Sort t/a Latitude Longitude
0 0 Wien CC 2272 48.201900 16.370000
1 1 Graz LD 426 47.079675 15.420325
2 2 Feldbach LD 248 46.952187 15.888309
3 3 Zerlach RE 2041 46.944865 15.650902
4 4 Gnas SM 1488 46.874198 15.826138
I get a syntax error???
Where is my error?
The cause of the error was probably that the latitude and longitude of the location information was not in list format. It is easier to handle the data frame with df.itertools(), so I modified the code. Also, the size of the circle is referenced by adding a new column as appropriate, so please fix this. The color and transparency of the circles have also been modified to make them easier to locate.
import pandas as pd
import numpy as np
import io
data = '''
Suburb Sort t/a Latitude Longitude
0 Wien CC 2272 48.201900 16.370000
1 Graz LD 426 47.079675 15.420325
2 Feldbach LD 248 46.952187 15.888309
3 Zerlach RE 2041 46.944865 15.650902
4 Gnas SM 1488 46.874198 15.826138
'''
df_locations = pd.read_csv(io.StringIO(data), delim_whitespace=True)
df_locations['points'] = np.random.randint(100, 500, (5,))
import folium
map_points = folium.Map(location=[47.210565, 15.8311348], zoom_start=7)
# for i in range(len(df_locations)):
for idx, row in df_locations.iterrows():
folium.Circle(
location=[row['Latitude'], row['Longitude']],
popup=row["Suburb"] + ": " + str(row["Sort"]),
radius = row['points']*100,
color="#dc143c",
fill=True,
opacity=1.0,
fill_color="#dc143c",
stroke=True,
weight=1.0,
).add_to(map_points)
map_points