Commit 11a67771 authored by Branko Kokanovic's avatar Branko Kokanovic

More info in visualization

parent ed0e53cf
......@@ -9,7 +9,7 @@ def has_elements(text):
return len(np.fromstring(text[1:-1], sep=',', dtype=int)) > 0
def get_values(csvfile, belgrade_only=False, format_v2=False):
def get_values(csvfile, district=None, municipality=None, format_v2=False):
df = pd.read_csv(csvfile)
if format_v2:
has_elements_v = np.vectorize(has_elements)
......@@ -18,8 +18,11 @@ def get_values(csvfile, belgrade_only=False, format_v2=False):
df['relation'] = df['relation'].apply(has_elements_v)
processed = df[df.processed == True]
if belgrade_only:
processed = processed[processed.district == 'ГРАД БЕОГРАД']
if district:
processed = processed[processed.district == district]
if municipality:
processed = processed[processed.municipality == municipality]
if format_v2:
processed = processed.assign(entity_found=(processed.node | processed.way | processed.relation))
else:
......@@ -35,9 +38,26 @@ def get_values(csvfile, belgrade_only=False, format_v2=False):
return [len(processed), len(entity_found), len(have_way), len(is_way_building), len(is_building_apartments)]
def main():
def print_funnel_per_district():
df = pd.read_csv('oktobar-result.csv')
print(["", "In RGZ", "Found in OSM", "Tagged as ways", "Tagged as building", "Tagged as apartments"])
for district in df.district.unique():
x = get_values('oktobar-result.csv', district=district, format_v2=True)
print(district, x)
def print_funnel_per_municipality():
df = pd.read_csv('oktobar-result.csv')
df = df[df.district == 'ГРАД БЕОГРАД']
print(["", "In RGZ", "Found in OSM", "Tagged as ways", "Tagged as building", "Tagged as apartments"])
for municipality in df.municipality.unique():
x = get_values('oktobar-result.csv', district='ГРАД БЕОГРАД', municipality=municipality, format_v2=True)
print(municipality, x)
def create_funnels():
# avgust-result.csv can be found at https://stambenezajednice.z6.web.core.windows.net/avgust2019.csv
x = get_values('avgust-result.csv', belgrade_only=False, format_v2=False)
x = get_values('avgust-result.csv', format_v2=False)
fig = go.Figure(go.Funnel(
x=x,
y=["In RGZ", "Found in OSM", "Tagged as ways", "Tagged as building", "Tagged as apartments"],
......@@ -48,7 +68,7 @@ def main():
))
fig.show()
x = get_values('avgust-result.csv', belgrade_only=True, format_v2=False)
x = get_values('avgust-result.csv', district='ГРАД БЕОГРАД', format_v2=False)
fig = go.Figure(go.Funnel(
x=x,
y=["In RGZ", "Found in OSM", "Tagged as ways", "Tagged as building", "Tagged as apartments"],
......@@ -60,7 +80,18 @@ def main():
fig.show()
# oktobar-result.csv can be found at https://stambenezajednice.z6.web.core.windows.net/oktobar2019.csv
x = get_values('oktobar-result.csv', belgrade_only=False, format_v2=True)
x = get_values('oktobar-result.csv', format_v2=True)
fig = go.Figure(go.Funnel(
x=x,
y=["In RGZ", "Found in OSM", "Tagged as ways", "Tagged as building", "Tagged as apartments"],
textinfo="label+value+percent initial",
marker={"color": [
"rgb(118,42,131)", "rgb(175,141,195)", "rgb(231,212,232)", "rgb(127,191,123)", "rgb(27,120,55)"]},
textfont={"size": 18}
))
fig.show()
x = get_values('oktobar-result.csv', district='ГРАД БЕОГРАД', format_v2=True)
fig = go.Figure(go.Funnel(
x=x,
y=["In RGZ", "Found in OSM", "Tagged as ways", "Tagged as building", "Tagged as apartments"],
......@@ -71,7 +102,7 @@ def main():
))
fig.show()
x = get_values('output.csv', belgrade_only=True, format_v2=True)
x = get_values('oktobar-result.csv', district='ГРАД БЕОГРАД', municipality='НОВИ БЕОГРАД', format_v2=True)
fig = go.Figure(go.Funnel(
x=x,
y=["In RGZ", "Found in OSM", "Tagged as ways", "Tagged as building", "Tagged as apartments"],
......@@ -84,4 +115,6 @@ def main():
if __name__ == '__main__':
main()
create_funnels()
print_funnel_per_district()
print_funnel_per_municipality()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment