Code
import altair as alt
import pandas as pd
= "https://www.statistik.at/wcm/idc/idcplg?IdcService=GET_NATIVE_FILE&RevisionSelectionMethod=LatestReleased&dDocName=126150"
preise_url = {
preise_urls "2016": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2016.xlsx",
"2017": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2017.xlsx",
"2018": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2018.xlsx",
"2019": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2019.xlsx",
"2020": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2020.xlsx"
}
= "https://raw.githubusercontent.com/ginseng666/GeoJSON-TopoJSON-Austria/master/2021/simplified-99.5/gemeinden_995_topo.json"
gemeinden_url = alt.topo_feature(gemeinden_url, "gemeinden")
gemeinden
def get_preise(year):
= pd.ExcelFile(preise_urls[year], engine='openpyxl')
xl = []
combined for s in xl.sheet_names:
= pd.read_excel(xl, engine='openpyxl', header=3, sheet_name=s)
sheet = sheet.iloc[:, -3:]
sheet = ['iso', 'name', 'price']
sheet.columns ~sheet.iso.isnull()])
combined.append(sheet.loc[return pd.concat(combined).reset_index(drop=True)
= get_preise("2020")
preise # preise.price = preise.price.clip(upper=300)
= alt.Chart(gemeinden).mark_geoshape().encode(
c =alt.Color('price:Q', title='Price', scale=alt.Scale(domain=[8, 2000], type='log', scheme='spectral', reverse=True)),
color=['name:N','price:Q']
tooltip
).transform_lookup(='properties.iso',
lookup=alt.LookupData(preise, 'iso', ['price', 'name'])
from_
).properties(=600,
width=310
height
)
c
Error loading script: Script error for "vega-embed"
https://requirejs.org/docs/errors.html#scripterror