%22%22%22Tutorial%203%3A%20read%20a%20table%20from%20Destatis%2C%20choose%20its%20years%20and%20categories%2C%20read%20the%20signs%20in%20its%20values.%0A%0ARun%20with%3A%20uv%20run%20marimo%20edit%20tutorials%2F03_destatis_table.py%20(needs%20network%20access%20and%20a%20free%20GENESIS-Online%20account).%0A%22%22%22%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.25.2%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%20Tutorial%203%3A%20a%20table%20from%20Destatis%0A%0A%20%20%20%20**Goal%3A**%20read%20a%20table%20from%20Destatis%2C%20Germany's%20Federal%20Statistical%20Office%2C%20choose%20its%20years%20and%0A%20%20%20%20categories%2C%20and%20read%20the%20signs%20it%20puts%20in%20place%20of%20numbers.%0A%0A%20%20%20%20**Time%3A**%20about%2015%20minutes%2C%20plus%20registering%20for%20a%20free%20account%20(same%20day).%20**You%20need%3A**%20basic%20Python%2C%0A%20%20%20%20a%20network%20connection%20and%20a%20GENESIS-Online%20account.%0A%0A%20%20%20%20**Setup%3A**%20clone%20the%20repository%20and%20run%20%60uv%20sync%20--all-extras%60%20(see%20the%20README)%2C%20get%20a%20token%20(below)%2C%20then%0A%20%20%20%20%60uv%20run%20marimo%20edit%20tutorials%2F03_destatis_table.py%60.%0A%0A%20%20%20%20Destatis%20publishes%20its%20tables%20in%20*GENESIS-Online*%2C%20its%20database.%20Every%20table%20has%20a%20code.%20Table%0A%20%20%20%20%6012411-0010%60%20counts%20the%20population%20of%20each%20*Land*%20(federal%20state%3B%20plural%20*L%C3%A4nder*)%20on%2031%20December%20of%0A%20%20%20%20each%20year.%20The%20day%20a%20count%20is%20taken%20on%20is%20its%20*Stichtag*%20(reference%20date).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%20Get%20a%20token%0A%0A%20%20%20%20Unlike%20tutorials%201%20and%202%2C%20GENESIS-Online%20needs%20an%20account.%0A%0A%20%20%20%201.%20Register%20for%20free%20at%20https%3A%2F%2Fgenesis.destatis.de%2Fdatenbank%2Fonline%2F.%0A%20%20%20%202.%20Log%20in.%20The%20web%20interface%20shows%20your%20token%20under%20*Webservice-Schnittstelle%20(API)*%20(web%20service%0A%20%20%20%20%20%20%20interface).%20Making%20a%20new%20token%20turns%20the%20old%20one%20off.%0A%20%20%20%203.%20In%20the%20repository%20folder%2C%20create%20a%20file%20named%20%60.env%60%20with%20one%20line%3A%20%60GENESIS_TOKEN%3D%60%20followed%20by%0A%20%20%20%20%20%20%20your%20token.%20git%20ignores%20this%20file%2C%20so%20the%20token%20stays%20out%20of%20the%20repository.%0A%20%20%20%204.%20Start%20marimo%20as%20in%20the%20setup%20line.%20It%20reads%20%60.env%60%20when%20it%20starts.%0A%0A%20%20%20%20A%20user%20name%20and%20password%20work%20too%20(%60GENESIS_USER%60%20and%20%60GENESIS_PASSWORD%60)%3B%20see%0A%20%20%20%20%5Bcredentials%5D(https%3A%2F%2Fgithub.com%2Fmloda-ai%2Fmloda-plugin-govdata%2Fblob%2Fmain%2Fdocs%2Fcredentials.md).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20altair%20as%20alt%0A%0A%20%20%20%20from%20mloda.user%20import%20DataAccessCollection%2C%20Feature%2C%20mloda%0A%20%20%20%20from%20mloda_plugin_govdata.feature_groups.destatis%20import%20(%0A%20%20%20%20%20%20%20%20GENESIS_ONLINE%2C%0A%20%20%20%20%20%20%20%20DestatisCredentials%2C%0A%20%20%20%20%20%20%20%20DestatisLocator%2C%0A%20%20%20%20%20%20%20%20DestatisReader%2C%0A%20%20%20%20%20%20%20%20MissingCredentialsError%2C%0A%20%20%20%20)%0A%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20DataAccessCollection%2C%0A%20%20%20%20%20%20%20%20DestatisCredentials%2C%0A%20%20%20%20%20%20%20%20DestatisLocator%2C%0A%20%20%20%20%20%20%20%20DestatisReader%2C%0A%20%20%20%20%20%20%20%20Feature%2C%0A%20%20%20%20%20%20%20%20GENESIS_ONLINE%2C%0A%20%20%20%20%20%20%20%20MissingCredentialsError%2C%0A%20%20%20%20%20%20%20%20alt%2C%0A%20%20%20%20%20%20%20%20mloda%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20DataAccessCollection%2C%0A%20%20%20%20DestatisCredentials%2C%0A%20%20%20%20GENESIS_ONLINE%2C%0A%20%20%20%20MissingCredentialsError%2C%0A%20%20%20%20mo%2C%0A)%3A%0A%20%20%20%20%23%20Every%20later%20cell%20takes%20a%20name%20from%20this%20cell%2C%20so%20mo.stop%20holds%20them%20all%20back.%0A%20%20%20%20_why%20%3D%20None%0A%20%20%20%20_collection%20%3D%20None%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20_credentials%20%3D%20DestatisCredentials.from_env(GENESIS_ONLINE)%0A%20%20%20%20%20%20%20%20if%20_credentials%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20_why%20%3D%20%22No%20token%20found%3A%20%60GENESIS_TOKEN%60%20is%20not%20set%20(nor%20%60GENESIS_USER%60%20and%20%60GENESIS_PASSWORD%60).%22%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20_collection%20%3D%20DataAccessCollection(credentials%3D%7B%22genesis%22%3A%20_credentials.to_credential()%7D)%0A%20%20%20%20except%20MissingCredentialsError%3A%20%20%23%20a%20user%20name%20without%20a%20password%2C%20or%20the%20reverse%0A%20%20%20%20%20%20%20%20_why%20%3D%20%22Set%20both%20%60GENESIS_USER%60%20and%20%60GENESIS_PASSWORD%60%2C%20or%20only%20%60GENESIS_TOKEN%60.%22%0A%20%20%20%20except%20ValueError%3A%20%20%23%20a%20character%20that%20cannot%20be%20part%20of%20a%20token%2C%20e.g.%20a%20copied%20quote%20mark%0A%20%20%20%20%20%20%20%20_why%20%3D%20%22The%20token%20contains%20a%20character%20that%20does%20not%20belong%20in%20it.%20Copy%20it%20again.%22%0A%20%20%20%20mo.stop(%0A%20%20%20%20%20%20%20%20_why%20is%20not%20None%2C%0A%20%20%20%20%20%20%20%20mo.md(f%22**Stopped.**%20%7B_why%7D%20Follow%20*Get%20a%20token*%20above%2C%20then%20start%20marimo%20again.%22)%2C%0A%20%20%20%20)%0A%20%20%20%20collection%20%3D%20_collection%0A%20%20%20%20TABLE%20%3D%20%2212411-0010%22%0A%20%20%20%20TABLE_BY_AGE%20%3D%20%2212411-0012%22%20%20%23%20the%20same%20count%2C%20split%20by%20age%20(Step%204)%0A%20%20%20%20return%20TABLE%2C%20TABLE_BY_AGE%2C%20collection%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%20Step%201%3A%20see%20the%20columns%0A%0A%20%20%20%20%60DestatisReader%60%20reads%20GENESIS%20tables.%20%60peek%60%20asks%20GENESIS%20for%20the%20table%20and%20lists%20the%20columns%20you%20can%0A%20%20%20%20ask%20for.%20If%20it%20fails%20with%20an%20authentication%20or%20backend%20error%2C%20copy%20your%20token%20again.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(DestatisReader%2C%20TABLE%2C%20collection)%3A%0A%20%20%20%20DestatisReader.peek(TABLE%2C%20collection)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20Every%20GENESIS%20table%20has%20the%20same%20kinds%20of%20columns%3A%0A%0A%20%20%20%20-%20%60statistics_...%60%3A%20which%20statistic%20the%20table%20belongs%20to.%0A%20%20%20%20-%20%60time%60%3A%20the%20year%2C%20a%20whole%20number.%20%60time_label%60%20says%20what%20kind%20of%20time%20it%20is%3A%20here%20*Stichtag*%2C%20so%20the%0A%20%20%20%20%20%20value%20is%20the%20count%20on%2031%20December%20of%20that%20year.%0A%20%20%20%20-%20%601_variable_...%60%3A%20the%20table's%20first%20variable%2C%20here%20the%20Land.%20%60..._attribute_code%60%20holds%20the%20Land's%0A%20%20%20%20%20%20official%20two-digit%20key%2C%20%60..._attribute_label%60%20its%20name.%20A%20table%20with%20more%20variables%20has%20%602_...%60%2C%20%603_...%60.%0A%20%20%20%20-%20%60value%60%3A%20the%20number.%20%60value_unit%60%20and%20%60value_variable_...%60%20say%20what%20it%20measures.%0A%20%20%20%20-%20%60value_marker%60%3A%20empty%20when%20the%20cell%20held%20a%20number.%20Otherwise%20the%20sign%20GENESIS%20wrote%20instead.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%20Step%202%3A%20read%20it%0A%0A%20%20%20%20Ask%20for%20the%20columns%20as%20features%2C%20as%20in%20tutorial%201.%20The%20option%20%60DestatisReader%3A%20TABLE%60%20picks%20the%20reader%0A%20%20%20%20and%20the%20table.%20GENESIS%20sends%20the%20rows%20in%20no%20fixed%20order%2C%20so%20sort%20them.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(DestatisReader%2C%20Feature%2C%20TABLE%2C%20collection%2C%20mloda)%3A%0A%20%20%20%20_columns%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%22time%22%2C%0A%20%20%20%20%20%20%20%20%22time_label%22%2C%0A%20%20%20%20%20%20%20%20%221_variable_attribute_code%22%2C%0A%20%20%20%20%20%20%20%20%221_variable_attribute_label%22%2C%0A%20%20%20%20%20%20%20%20%22value%22%2C%0A%20%20%20%20%20%20%20%20%22value_marker%22%2C%0A%20%20%20%20%5D%0A%20%20%20%20_result%20%3D%20mloda.run_all(%0A%20%20%20%20%20%20%20%20%5BFeature(_name%2C%20options%3D%7BDestatisReader%3A%20TABLE%7D)%20for%20_name%20in%20_columns%5D%2C%0A%20%20%20%20%20%20%20%20compute_frameworks%3D%5B%22PyArrowTable%22%5D%2C%0A%20%20%20%20%20%20%20%20column_ordering%3D%22request_order%22%2C%0A%20%20%20%20%20%20%20%20data_access_collection%3Dcollection%2C%0A%20%20%20%20)%0A%20%20%20%20population%20%3D%20_result%5B0%5D.to_pandas().sort_values(%5B%221_variable_attribute_code%22%2C%20%22time%22%5D%2C%20ignore_index%3DTrue)%0A%20%20%20%20population%0A%20%20%20%20return%20(population%2C)%0A%0A%0A%40app.cell%0Adef%20_(mo%2C%20population)%3A%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20One%20row%20per%20Land%20and%20year.%20You%20did%20not%20say%20which%20years%2C%20so%20GENESIS%20chose%3A%20%7Bpopulation%5B%22time%22%5D.min()%7D%20to%0A%20%20%20%20%7Bpopulation%5B%22time%22%5D.max()%7D.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%20Step%203%3A%20choose%20the%20years%0A%0A%20%20%20%20A%20%60DestatisLocator%60%20names%20the%20table%20plus%20what%20to%20select%20from%20it.%20%60startyear%60%20and%20%60endyear%60%20pick%20the%0A%20%20%20%20years%3B%20leave%20one%20out%20and%20the%20range%20stays%20open%20on%20that%20side.%20Other%20fields%20pick%20regions%20or%20categories%2C%20see%0A%20%20%20%20%5BDestatis%20options%5D(https%3A%2F%2Fgithub.com%2Fmloda-ai%2Fmloda-plugin-govdata%2Fblob%2Fmain%2Fdocs%2Fdestatis-options.md).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(DestatisLocator%2C%20DestatisReader%2C%20Feature%2C%20TABLE%2C%20collection%2C%20mloda)%3A%0A%20%20%20%20since_1980%20%3D%20DestatisLocator(TABLE%2C%20startyear%3D1980)%0A%20%20%20%20_columns%20%3D%20%5B%22time%22%2C%20%221_variable_attribute_code%22%2C%20%221_variable_attribute_label%22%2C%20%22value%22%2C%20%22value_marker%22%5D%0A%20%20%20%20_result%20%3D%20mloda.run_all(%0A%20%20%20%20%20%20%20%20%5BFeature(_name%2C%20options%3D%7BDestatisReader%3A%20since_1980%7D)%20for%20_name%20in%20_columns%5D%2C%0A%20%20%20%20%20%20%20%20compute_frameworks%3D%5B%22PyArrowTable%22%5D%2C%0A%20%20%20%20%20%20%20%20column_ordering%3D%22request_order%22%2C%0A%20%20%20%20%20%20%20%20data_access_collection%3Dcollection%2C%0A%20%20%20%20)%0A%20%20%20%20history%20%3D%20_result%5B0%5D.to_pandas().sort_values(%5B%221_variable_attribute_code%22%2C%20%22time%22%5D%2C%20ignore_index%3DTrue)%0A%20%20%20%20history%0A%20%20%20%20return%20history%2C%20since_1980%0A%0A%0A%40app.cell%0Adef%20_(history%2C%20mo)%3A%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%7Blen(history)%7D%20rows%3A%2016%20L%C3%A4nder%2C%20%7Bhistory%5B%22time%22%5D.min()%7D%20to%20%7Bhistory%5B%22time%22%5D.max()%7D.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%20Step%204%3A%20choose%20a%20category%0A%0A%20%20%20%20Table%20%6012411-0010%60%20has%20no%20categories%20besides%20the%20Land.%20Its%20sibling%20table%20%6012411-0012%60%20holds%20the%20same%0A%20%20%20%20count%2C%20split%20by%20age%20in%20years%20(*Altersjahre*).%20A%20category%20is%20a%20*classifying%20variable*%20in%20GENESIS%3B%20this%20one%0A%20%20%20%20has%20the%20code%20%60ALT103%60%2C%20and%20its%20values%20have%20codes%20too%3A%20%60ALT000%60%20(under%201%20year)%2C%20%60ALT001%60%20(1%20year)%20and%20so%0A%20%20%20%20on%2C%20up%20to%20%60ALT090UM%60%20(90%20years%20and%20over).%20The%20codes%20are%20listed%20on%20the%0A%20%20%20%20%5Btable's%20page%5D(https%3A%2F%2Fgenesis.destatis.de%2Fdatenbank%2Fonline%2Fstatistic%2F12411%2Ftable%2F12411-0012).%0A%0A%20%20%20%20%60classifyingvariable1%60%20names%20the%20category%2C%20%60classifyingkey1%60%20the%20values%20to%20keep.%20Here%3A%20children%20under%0A%20%20%20%201%20year%20only.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20DestatisLocator%2C%0A%20%20%20%20DestatisReader%2C%0A%20%20%20%20Feature%2C%0A%20%20%20%20TABLE_BY_AGE%2C%0A%20%20%20%20collection%2C%0A%20%20%20%20mloda%2C%0A)%3A%0A%20%20%20%20under_one%20%3D%20DestatisLocator(TABLE_BY_AGE%2C%20classifyingvariable1%3D%22ALT103%22%2C%20classifyingkey1%3D%5B%22ALT000%22%5D)%0A%20%20%20%20_columns%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%22time%22%2C%0A%20%20%20%20%20%20%20%20%221_variable_attribute_label%22%2C%0A%20%20%20%20%20%20%20%20%222_variable_attribute_code%22%2C%0A%20%20%20%20%20%20%20%20%222_variable_attribute_label%22%2C%0A%20%20%20%20%20%20%20%20%22value%22%2C%0A%20%20%20%20%5D%0A%20%20%20%20_result%20%3D%20mloda.run_all(%0A%20%20%20%20%20%20%20%20%5BFeature(_name%2C%20options%3D%7BDestatisReader%3A%20under_one%7D)%20for%20_name%20in%20_columns%5D%2C%0A%20%20%20%20%20%20%20%20compute_frameworks%3D%5B%22PyArrowTable%22%5D%2C%0A%20%20%20%20%20%20%20%20column_ordering%3D%22request_order%22%2C%0A%20%20%20%20%20%20%20%20data_access_collection%3Dcollection%2C%0A%20%20%20%20)%0A%20%20%20%20by_age%20%3D%20_result%5B0%5D.to_pandas().sort_values(%5B%221_variable_attribute_label%22%2C%20%22value%22%5D%2C%20ignore_index%3DTrue)%0A%20%20%20%20by_age%0A%20%20%20%20return%20by_age%2C%20under_one%0A%0A%0A%40app.cell%0Adef%20_(by_age%2C%20mo)%3A%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20The%20age%20is%20the%20second%20variable%2C%20so%20its%20columns%20start%20with%20%602_%60.%20You%20asked%20for%20one%20age%2C%20yet%20there%20are%0A%20%20%20%20%7Blen(by_age)%7D%20rows%2C%20two%20per%20Land%3A%20GENESIS%20adds%20the%20total%2C%20*Insgesamt*%2C%20too.%20Its%20code%20is%20missing%20(pandas%0A%20%20%20%20shows%20%60NaN%60).%20Adding%20up%20the%20%60value%60%20column%20would%20add%20the%20whole%20population%20on%20top%20of%20the%20children.%20Keep%20the%0A%20%20%20%20rows%20whose%20code%20you%20asked%20for%3A%0A%20%20%20%20%60by_age%5Bby_age%5B%222_variable_attribute_code%22%5D%20%3D%3D%20%22ALT000%22%5D%60.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%20Pitfall%3A%20a%20dash%20that%20means%20%22did%20not%20exist%22%0A%0A%20%20%20%20Here%20is%20Brandenburg%2C%20from%20Step%203%2C%20around%201990%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(history)%3A%0A%20%20%20%20_brandenburg%20%3D%20history%5Bhistory%5B%221_variable_attribute_label%22%5D%20%3D%3D%20%22Brandenburg%22%5D%0A%20%20%20%20_brandenburg%5B_brandenburg%5B%22time%22%5D.between(1987%2C%201992)%5D%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20Until%201989%20the%20value%20is%200%20and%20%60value_marker%60%20is%20%60-%60.%20In%20GENESIS%2C%20%60-%60%20means%20%22nothing%20there%22%2C%20so%20the%0A%20%20%20%20plugin%20reads%20it%20as%200%20and%20keeps%20the%20sign.%20Here%20it%20means%20the%20Land%20did%20not%20exist%20yet%3A%20Brandenburg%20and%20the%0A%20%20%20%20other%20eastern%20L%C3%A4nder%20joined%20the%20count%20in%201990%2C%20after%20German%20reunification.%20Ask%20which%20Land%20was%20smallest%0A%20%20%20%20in%201989%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(history%2C%20mo)%3A%0A%20%20%20%20_year_1989%20%3D%20history%5Bhistory%5B%22time%22%5D%20%3D%3D%201989%5D%0A%20%20%20%20_with_dashes%20%3D%20_year_1989.nsmallest(1%2C%20%22value%22).iloc%5B0%5D%0A%20%20%20%20_without_dashes%20%3D%20_year_1989%5B_year_1989%5B%22value_marker%22%5D%20!%3D%20%22-%22%5D.nsmallest(1%2C%20%22value%22).iloc%5B0%5D%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20-%20All%20rows%3A%20%7B_with_dashes%5B%221_variable_attribute_label%22%5D%7D%2C%20%7B_with_dashes%5B%22value%22%5D%3A%2C.0f%7D%20people.%0A%20%20%20%20-%20Without%20the%20%60-%60%20rows%3A%20%7B_without_dashes%5B%221_variable_attribute_label%22%5D%7D%2C%20%7B_without_dashes%5B%22value%22%5D%3A%2C.0f%7D%20people.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20The%20table's%20page%20has%20a%20note%20that%20explains%20this%2C%20but%20the%20note%20does%20not%20come%20with%20the%20data.%20So%20look%20at%0A%20%20%20%20%60value_marker%60%20before%20you%20compare%20or%20add%20up.%20The%20other%20signs%20(such%20as%20%60.%60%20for%20unknown%20or%20secret)%20are%20read%0A%20%20%20%20as%20missing%20values%3B%20%60value_marker%60%20keeps%20them%20too.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%20Try%20it%3A%20pick%20a%20Land%0A%0A%20%20%20%20The%20chart%20shows%20the%20Land's%20population%20on%2031%20December%20of%20each%20year%2C%20without%20the%20%60-%60%20rows.%20It%20starts%20with%0A%20%20%20%20Berlin%3A%20until%201989%20it%20counts%20West%20Berlin%20only%2C%20so%20the%20line%20jumps%20in%201990.%20Every%20Land%20drops%20from%202010%20to%0A%20%20%20%202011%3A%20from%202011%20the%20counts%20rest%20on%20a%20new%20census%2C%20which%20corrected%20them.%20From%202022%20a%20newer%20census%20is%20the%0A%20%20%20%20base%2C%20so%20the%20step%20from%202021%20to%202022%20mixes%20a%20correction%20with%20real%20change.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(history%2C%20mo)%3A%0A%20%20%20%20_names%20%3D%20sorted(history%5B%221_variable_attribute_label%22%5D.unique())%0A%20%20%20%20land%20%3D%20mo.ui.dropdown(options%3D_names%2C%20value%3D%22Berlin%22%20if%20%22Berlin%22%20in%20_names%20else%20_names%5B0%5D%2C%20label%3D%22Land%22)%0A%20%20%20%20land%0A%20%20%20%20return%20(land%2C)%0A%0A%0A%40app.cell%0Adef%20_(alt%2C%20history%2C%20land)%3A%0A%20%20%20%20_rows%20%3D%20history%5B(history%5B%221_variable_attribute_label%22%5D%20%3D%3D%20land.value)%20%26%20(history%5B%22value_marker%22%5D%20!%3D%20%22-%22)%5D%0A%20%20%20%20alt.Chart(_rows%2C%20title%3Df%22Population%20of%20%7Bland.value%7D%20on%2031%20December%22).mark_line(point%3DTrue).encode(%0A%20%20%20%20%20%20%20%20x%3Dalt.X(%22time%3AQ%22%2C%20title%3D%22Year%22%2C%20axis%3Dalt.Axis(format%3D%22d%22))%2C%0A%20%20%20%20%20%20%20%20y%3Dalt.Y(%22value%3AQ%22%2C%20title%3D%22People%22)%2C%0A%20%20%20%20%20%20%20%20tooltip%3D%5B%22time%22%2C%20%22value%22%5D%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20%23%23%20Where%20the%20data%20came%20from%0A%0A%20%20%20%20Every%20published%20number%20needs%20its%20source.%20Both%20tables%20come%20from%20Destatis%20under%20one%20license%3B%20the%20copy%20on%0A%20%20%20%20your%20disk%20records%20when%20you%20downloaded%20each%20selection.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(DestatisReader%2C%20TABLE%2C%20TABLE_BY_AGE%2C%20mo%2C%20since_1980%2C%20under_one)%3A%0A%20%20%20%20def%20_retrieved(selection)%3A%0A%20%20%20%20%20%20%20%20%23%20The%20copy%20each%20step%20read%3B%20a%20missing%20one%20means%20the%20cache%20was%20cleared%20since.%0A%20%20%20%20%20%20%20%20_copy%20%3D%20DestatisReader.retrieval(selection)%0A%20%20%20%20%20%20%20%20return%20f%22%7B_copy.retrieved_at%3A%25Y-%25m-%25d%7D%22%20if%20_copy%20else%20%22not%20in%20the%20local%20cache%20any%20more%22%0A%0A%20%20%20%20_page%20%3D%20%22https%3A%2F%2Fgenesis.destatis.de%2Fdatenbank%2Fonline%2Fstatistic%2F12411%2Ftable%2F%22%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20-%20**Source%3A**%20Statistisches%20Bundesamt%20(Destatis)%2C%20GENESIS-Online%0A%20%20%20%20-%20**License%3A**%20%60%7BDestatisReader.LICENSE%7D%60%2C%20the%20id%20the%20reader%20declares%20for%20Destatis%20data%0A%20%20%20%20-%20**Table%20%7BTABLE%7D%3A**%20%7B_page%7D%7BTABLE%7D%2C%20retrieved%20%7B_retrieved(TABLE)%7D%20(Steps%201%20and%202)%20and%0A%20%20%20%20%20%20%7B_retrieved(since_1980)%7D%20(Step%203)%0A%20%20%20%20-%20**Table%20%7BTABLE_BY_AGE%7D%3A**%20%7B_page%7D%7BTABLE_BY_AGE%7D%2C%20retrieved%20%7B_retrieved(under_one)%7D%20(Step%204)%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%0A%20%20%20%20The%20license%2C%20%5BData%20License%20Germany%2C%20attribution%2C%20version%202.0%5D(https%3A%2F%2Fwww.govdata.de%2Fdl-de%2Fby-2-0)%2C%0A%20%20%20%20lets%20you%20reuse%20the%20data%20if%20you%20name%20the%20source%2C%20link%20the%20license%20and%20say%20what%20you%20changed.%20The%20plugin%0A%20%20%20%20changed%20two%20things%20for%20every%20table%3A%20each%20reference%20date%20became%20its%20year%2C%20and%20each%20%60-%60%20became%200%20(the%20sign%0A%20%20%20%20stays%20in%20%60value_marker%60).%20Here%20you%20also%20kept%20the%20years%20from%201980%20of%20table%2012411-0010%20and%20left%20out%20its%0A%20%20%20%20%60-%60%20rows%20in%20the%20chart.%0A%0A%20%20%20%20%23%23%20Next%0A%0A%20%20%20%20The%20next%20tutorial%20puts%20districts%20(*Kreise*)%20on%20today's%20borders%2C%20with%20the%20same%20account.%0A%20%20%20%20%5BDestatis%20options%5D(https%3A%2F%2Fgithub.com%2Fmloda-ai%2Fmloda-plugin-govdata%2Fblob%2Fmain%2Fdocs%2Fdestatis-options.md)%0A%20%20%20%20lists%20everything%20a%20%60DestatisLocator%60%20can%20select%20and%20every%20output%20column.%0A%20%20%20%20%5BCredentials%5D(https%3A%2F%2Fgithub.com%2Fmloda-ai%2Fmloda-plugin-govdata%2Fblob%2Fmain%2Fdocs%2Fcredentials.md)%20covers%0A%20%20%20%20the%20account%2C%20the%20token%20and%20the%20second%20GENESIS%20database%2C%20Regionalstatistik.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
68485cce84d21b6c125009dcd220746a