%22%22%22Tutorial%205%3A%20run%20a%20recipe%2C%20join%20two%20sources%2C%20and%20read%20where%20every%20number%20came%20from.%0A%0ARun%20with%3A%20uv%20run%20marimo%20edit%20tutorials%2F05_recipes_and_provenance.py%20(needs%20network%20access%20and%20a%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%205%3A%20recipes%20and%20provenance%0A%0A%20%20%20%20**Goal%3A**%20run%20a%20result%20from%20a%20recipe%20file%2C%20join%20two%20sources%2C%20and%20read%20where%20every%20number%20came%20from.%0A%0A%20%20%20%20**Time%3A**%20about%2015%20minutes.%20**You%20need%3A**%20basic%20Python%2C%20a%20network%20connection%2C%20the%20GENESIS-Online%20token%0A%20%20%20%20from%20tutorial%203%2C%20and%20a%20clone%20of%20the%20repository%3A%20recipe%20files%20sit%20in%20its%20%60recipes%2F%60%20folder%2C%20not%20in%20the%0A%20%20%20%20installed%20package.%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%20put%20your%20token%20in%0A%20%20%20%20%60.env%60%20as%20in%20tutorial%203%2C%20then%20%60uv%20run%20marimo%20edit%20tutorials%2F05_recipes_and_provenance.py%60.%0A%0A%20%20%20%20A%20*recipe*%20is%20a%20small%20file%20that%20writes%20one%20result%20down%3A%20which%20columns%20to%20read%20from%20which%20sources%2C%20how%0A%20%20%20%20to%20join%20them%2C%20and%20where%20the%20data%20came%20from.%20Anyone%20with%20the%20file%20can%20run%20the%20same%20result%20again.%20This%0A%20%20%20%20tutorial%20runs%20the%20recipe%20for%20the%20number%20of%20people%20per%20eligible%20voter%20in%20each%20*Land*%20(federal%20state%3B%0A%20%20%20%20plural%20*L%C3%A4nder*)%3A%20population%20counts%20from%20Destatis%20on%20one%20side%2C%20the%202025%20election%20to%20the%20*Bundestag*%0A%20%20%20%20(the%20federal%20parliament)%20on%20the%20other.%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%20pandas%20as%20pd%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%20DestatisReader%2C%0A%20%20%20%20%20%20%20%20MissingCredentialsError%2C%0A%20%20%20%20)%0A%20%20%20%20from%20mloda_plugin_govdata.feature_groups.govdata%20import%20BundeswahlleiterinReader%0A%20%20%20%20from%20mloda_plugin_govdata.feature_groups.harmonization%20import%20check_land_names%0A%20%20%20%20from%20mloda_plugin_govdata.feature_groups.land_population_per_voter%20import%20LAND_LOCATOR%2C%20LandPopulationPerVoter%0A%20%20%20%20from%20mloda_plugin_govdata.recipes%20import%20load_recipe%0A%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20BundeswahlleiterinReader%2C%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%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%20LAND_LOCATOR%2C%0A%20%20%20%20%20%20%20%20LandPopulationPerVoter%2C%0A%20%20%20%20%20%20%20%20MissingCredentialsError%2C%0A%20%20%20%20%20%20%20%20check_land_names%2C%0A%20%20%20%20%20%20%20%20load_recipe%2C%0A%20%20%20%20%20%20%20%20mloda%2C%0A%20%20%20%20%20%20%20%20pd%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%20if%20_why%20is%20not%20None%3A%0A%20%20%20%20%20%20%20%20_why%20%2B%3D%20%22%20See%20*Get%20a%20token*%20in%20tutorial%203%2C%20then%20start%20marimo%20again.%22%0A%20%20%20%20elif%20mo.notebook_dir()%20is%20None%20or%20not%20(mo.notebook_dir().parent%20%2F%20%22recipes%22).is_dir()%3A%0A%20%20%20%20%20%20%20%20_why%20%3D%20%22This%20notebook%20cannot%20find%20the%20%60recipes%2F%60%20folder.%20Open%20it%20from%20your%20clone%20of%20the%20repository.%22%0A%20%20%20%20mo.stop(_why%20is%20not%20None%2C%20mo.md(f%22**Stopped.**%20%7B_why%7D%22))%0A%20%20%20%20collection%20%3D%20_collection%0A%20%20%20%20recipes%20%3D%20mo.notebook_dir().parent%20%2F%20%22recipes%22%0A%20%20%20%20return%20collection%2C%20recipes%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%20open%20the%20recipe%0A%0A%20%20%20%20%60load_recipe%60%20reads%20a%20recipe%20file%20and%20returns%20three%20things%3A%20%60features%60%2C%20the%20columns%20to%20read%2C%20ready%20for%0A%20%20%20%20%60mloda.run_all%60%3B%20%60links%60%2C%20how%20to%20join%20the%20sources%3B%20and%20%60compliance%60%2C%20where%20the%20data%20came%20from.%0A%0A%20%20%20%20The%20first%20five%20features%20are%20columns%20of%20Destatis%20table%20%6012411-0010%60%20from%20tutorial%203%2C%20for%20the%20year%202024.%0A%20%20%20%20The%20other%20five%20are%20columns%20of%20%60kerg.csv%60%2C%20the%20results%20file%20of%20the%20*Bundeswahlleiterin*%20(the%20federal%0A%20%20%20%20returning%20officer)%3A%20%60Nr%60%20is%20an%20area's%20number%2C%20%60Gebiet%60%20its%20name%2C%20%60geh%C3%B6rt%20zu%60%20(belongs%20to)%20the%20number%20of%0A%20%20%20%20the%20area%20it%20is%20part%20of%2C%20then%20the%20eligible%20voters%20and%20the%20votes%20for%20one%20party.%20The%20election%20took%20place%20on%0A%20%20%20%2023%20February%202025%2C%20so%20it%20is%20paired%20with%20the%20population%20of%2031%20December%202024%2C%20the%20last%20count%20before%20it.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(load_recipe%2C%20recipes)%3A%0A%20%20%20%20recipe%20%3D%20load_recipe(recipes%20%2F%20%22land_population_per_voter.json%22)%0A%20%20%20%20%5Bstr(_feature.name)%20for%20_feature%20in%20recipe.features%5D%0A%20%20%20%20return%20(recipe%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%23%20Step%202%3A%20run%20it%0A%0A%20%20%20%20Hand%20the%20recipe's%20features%20to%20%60mloda.run_all%60%2C%20like%20any%20list%20of%20features.%20%60frame_for%60%20picks%20a%20result%0A%20%20%20%20table%20by%20a%20feature%20it%20holds%3A%20%60value%60%20is%20only%20on%20the%20Destatis%20side%2C%20%60Nr%60%20only%20on%20the%20election%20side.%20The%0A%20%20%20%20election%20file%20also%20has%20rows%20for%20constituencies%20and%20for%20Germany%20as%20a%20whole%3B%20a%20Land%20belongs%20to%20%6099%60%2C%20the%0A%20%20%20%20number%20of%20Germany%20as%20a%20whole%2C%20so%20%60geh%C3%B6rt%20zu%20%3D%3D%20%2299%22%60%20keeps%20the%20L%C3%A4nder.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(collection%2C%20mloda%2C%20recipe)%3A%0A%20%20%20%20_result%20%3D%20mloda.run_all(%0A%20%20%20%20%20%20%20%20recipe.features%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.frame_for(%22value%22).to_pandas().sort_values(%221_variable_attribute_code%22%2C%20ignore_index%3DTrue)%0A%20%20%20%20election%20%3D%20_result.frame_for(%22Nr%22).to_pandas()%0A%20%20%20%20lands%20%3D%20election%5Belection%5B%22geh%C3%B6rt%20zu%22%5D%20%3D%3D%20%2299%22%5D.sort_values(%22Nr%22%2C%20ignore_index%3DTrue)%0A%20%20%20%20lands%0A%20%20%20%20return%20election%2C%20lands%2C%20population%0A%0A%0A%40app.cell%0Adef%20_(check_land_names%2C%20election%2C%20lands%2C%20mo%2C%20population)%3A%0A%20%20%20%20%23%20check_land_names%20raises%20an%20error%20if%20a%20number%20and%20its%20name%20disagree%2C%20a%20number%20repeats%2C%20or%20a%20Land%20is%20missing.%0A%20%20%20%20check_land_names(zip(population%5B%221_variable_attribute_code%22%5D%2C%20population%5B%221_variable_attribute_label%22%5D))%0A%20%20%20%20check_land_names(zip(lands%5B%22Nr%22%5D%2C%20lands%5B%22Gebiet%22%5D))%0A%20%20%20%20_constituencies%20%3D%20election%5B%22geh%C3%B6rt%20zu%22%5D.isin(lands%5B%22Nr%22%5D).sum()%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20Two%20tables%2C%20one%20per%20source%2C%20not%20one%20joined%20table%3A%20mloda%20joins%20only%20for%20a%20feature%20that%20needs%20columns%20from%0A%20%20%20%20both%20sides%20(Step%203).%20The%20population%20table%20(not%20shown)%20has%20%7Blen(population)%7D%20rows%2C%20one%20per%20Land.%20The%20election%20table%0A%20%20%20%20has%20%7Blen(election)%7D%3A%20%7B_constituencies%7D%20constituencies%20(*Wahlkreise*)%2C%20%7Blen(lands)%7D%20L%C3%A4nder%20and%20Germany%20as%0A%20%20%20%20a%20whole.%0A%0A%20%20%20%20Both%20sides%20number%20the%20L%C3%A4nder%20the%20same%20way%2C%20with%20the%20first%20two%20digits%20of%20the%20*AGS*%20(the%20official%20region%0A%20%20%20%20key)%2C%20from%20%6001%60%20Schleswig-Holstein%20to%20%6016%60%20Th%C3%BCringen.%20%60check_land_names%60%20passed%20on%20both%3A%20each%20side%20names%0A%20%20%20%20all%2016%20L%C3%A4nder%2C%20and%20every%20number%20matches%20its%20name.%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%20join%20the%20two%20sources%0A%0A%20%20%20%20The%20recipe's%20%60links%60%20hold%20the%20join%3A%20Destatis%20%601_variable_attribute_code%60%20to%20election%20%60Nr%60.%20mloda%20uses%0A%20%20%20%20such%20a%20link%20only%20for%20a%20feature%20that%20needs%20columns%20from%20both%20sides.%20%60LandPopulationPerVoter%60%20is%20one%3A%20it%0A%20%20%20%20reads%20the%20same%20table%20and%20file%20as%20the%20recipe%2C%20declares%20the%20same%20link%2C%20joins%20the%20two%20per%20Land%20and%20divides%0A%20%20%20%20the%20population%20by%20the%20eligible%20voters.%20Ask%20for%20it%20by%20its%20name.%20Like%20%60value__rebased%60%20in%20tutorial%204%2C%20the%0A%20%20%20%20result%20has%20several%20parts%2C%20named%20%60land_population_per_voter~%3Cpart%3E%60.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(Feature%2C%20LandPopulationPerVoter%2C%20collection%2C%20mloda%2C%20recipe)%3A%0A%20%20%20%20_after_step_1%20%3D%20recipe%20%20%23%20waits%20for%20the%20token%20check%20and%20Step%201%0A%20%20%20%20_table%20%3D%20mloda.run_all(%0A%20%20%20%20%20%20%20%20%5BFeature(LandPopulationPerVoter.NAME)%5D%2C%20compute_frameworks%3D%5B%22PyArrowTable%22%5D%2C%20data_access_collection%3Dcollection%0A%20%20%20%20)%5B0%5D%0A%20%20%20%20per_voter%20%3D%20_table.to_pandas()%0A%20%20%20%20per_voter.columns%20%3D%20%5B_name.rpartition(%22~%22)%5B2%5D%20for%20_name%20in%20per_voter.columns%5D%20%20%23%20keep%20only%20the%20part%20name%0A%20%20%20%20per_voter%5B%5B%22code%22%2C%20%22land%22%2C%20%22population%22%2C%20%22voters%22%2C%20%22value%22%5D%5D%0A%20%20%20%20return%20(per_voter%2C)%0A%0A%0A%40app.cell%0Adef%20_(mo%2C%20per_voter)%3A%0A%20%20%20%20_ranked%20%3D%20per_voter.sort_values(%22value%22)%0A%20%20%20%20_lowest%2C%20_highest%20%3D%20_ranked.iloc%5B0%5D%2C%20_ranked.iloc%5B-1%5D%0A%20%20%20%20_above_one%20%3D%20(%0A%20%20%20%20%20%20%20%20%22%20Every%20value%20is%20above%201%3A%20children%20and%20people%20without%20German%20citizenship%20count%20in%20the%20population%20but%22%0A%20%20%20%20%20%20%20%20%22%20cannot%20vote%20for%20the%20Bundestag.%22%0A%20%20%20%20%20%20%20%20if%20(per_voter%5B%22value%22%5D%20%3E%201).all()%0A%20%20%20%20%20%20%20%20else%20%22%22%0A%20%20%20%20)%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20One%20row%20per%20Land.%20%60value%60%20is%20the%20population%20divided%20by%20the%20eligible%20voters%3A%20%7B_highest%5B%22land%22%5D%7D%20has%20the%0A%20%20%20%20most%20people%20per%20voter%20(%7B_highest%5B%22value%22%5D%3A.2f%7D)%2C%20%7B_lowest%5B%22land%22%5D%7D%20the%20fewest%20(%7B_lowest%5B%22value%22%5D%3A.2f%7D).%7B_above_one%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%20Pitfall%3A%20empty%20is%20not%20zero%0A%0A%20%20%20%20The%20recipe%20also%20reads%20the%20final%20(*Endg%C3%BCltig*)%20*Zweitstimmen*%20(second%20votes%2C%20the%20vote%20for%20a%20party's%20list)%0A%20%20%20%20of%20the%20CSU.%20The%20CSU%20and%20the%20CDU%20are%20sister%20parties%20that%20never%20stand%20against%20each%20other%3A%20the%20CSU%20stands%0A%20%20%20%20only%20in%20Bayern%20(Bavaria)%2C%20the%20CDU%20everywhere%20else.%20So%20the%20CSU%20cell%20is%20empty%20in%20every%20other%20Land.%20Empty%0A%20%20%20%20means%20%22not%20on%20the%20ballot%22%2C%20not%20%22no%20votes%22.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(lands%2C%20mo)%3A%0A%20%20%20%20_csu%20%3D%20lands.set_index(%22Gebiet%22)%5B%22Christlich-Soziale%20Union%20in%20Bayern%20e.V.%20Zweitstimmen%20Endg%C3%BCltig%22%5D%0A%20%20%20%20_counted%20%3D%20%22%2C%20%22.join(f%22%7B_land%7D%20(%7B_votes%3A%2C.0f%7D%20votes)%22%20for%20_land%2C%20_votes%20in%20_csu.dropna().items())%0A%20%20%20%20_stood%20%3D%20%22the%20Land%22%20if%20_csu.count()%20%3D%3D%201%20else%20f%22the%20%7B_csu.count()%7D%20L%C3%A4nder%22%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20The%20CSU%20column%20has%20a%20number%20only%20for%20%7B_counted%7D%20and%20is%20empty%20for%20the%20other%20%7B_csu.isna().sum()%7D%20L%C3%A4nder.%0A%20%20%20%20pandas%20shows%20an%20empty%20cell%20as%20%60NaN%60%20(not%20a%20number)%2C%20and%20%60.mean()%60%20skips%20it%3A%20the%20mean%20of%20the%20column%20is%0A%20%20%20%20%7B_csu.mean()%3A%2C.0f%7D%2C%20taken%20over%20%7B_stood%7D%20where%20the%20CSU%20stood.%20Fill%20the%20empty%20cells%20with%200%20first%0A%20%20%20%20(%60.fillna(0).mean()%60)%20and%20the%20mean%20drops%20to%20%7B_csu.fillna(0).mean()%3A%2C.0f%7D%3A%20every%20Land%20where%20nobody%20could%0A%20%20%20%20vote%20for%20the%20CSU%20now%20counts%20as%20zero%20votes.%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%20read%20another%20recipe%0A%0A%20%20%20%20The%20repository%20ships%20more%20recipes.%20Pick%20one%20to%20see%20its%20sources%20as%20its%20compliance%20block%20writes%20them%20down.%0A%20%20%20%20Nothing%20is%20downloaded%3A%20the%20file%20alone%20says%20where%20its%20data%20comes%20from%20and%20under%20which%20license.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo%2C%20recipes)%3A%0A%20%20%20%20_names%20%3D%20sorted(_path.name%20for%20_path%20in%20recipes.glob(%22*.json%22))%0A%20%20%20%20picked%20%3D%20mo.ui.dropdown(options%3D_names%2C%20value%3D_names%5B0%5D%2C%20label%3D%22Recipe%22)%0A%20%20%20%20picked%0A%20%20%20%20return%20(picked%2C)%0A%0A%0A%40app.cell%0Adef%20_(load_recipe%2C%20pd%2C%20picked%2C%20recipes)%3A%0A%20%20%20%20_sources%20%3D%20load_recipe(recipes%20%2F%20picked.value).compliance.sources%0A%20%20%20%20pd.DataFrame(%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22source%22%3A%20%5B_source.attribution%20for%20_source%20in%20_sources%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22license%22%3A%20%5B_source.license%20for%20_source%20in%20_sources%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22downloaded%20by%20the%20recipe's%20author%22%3A%20%5Bf%22%7B_source.retrieved_at%3A%25Y-%25m-%25d%7D%22%20for%20_source%20in%20_sources%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22address%22%3A%20%5B_source.dataset_uri%20for%20_source%20in%20_sources%5D%2C%0A%20%20%20%20%20%20%20%20%7D%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%20The%20compliance%20block%20of%20the%20recipe%20from%20Step%201%20names%20each%20source%20with%20its%20license%20and%20attribution%2C%20the%0A%20%20%20%20day%20the%20recipe's%20author%20downloaded%20it%2C%20and%20a%20*checksum*%20(sha256)%3A%20a%20fingerprint%20of%20the%20downloaded%20file.%0A%20%20%20%20The%20copies%20on%20your%20disk%20carry%20their%20own%20download%20date%20and%20checksum.%20The%20same%20checksum%20means%20the%20same%0A%20%20%20%20file.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20BundeswahlleiterinReader%2C%0A%20%20%20%20DestatisReader%2C%0A%20%20%20%20LAND_LOCATOR%2C%0A%20%20%20%20mo%2C%0A%20%20%20%20per_voter%2C%0A%20%20%20%20recipe%2C%0A)%3A%0A%20%20%20%20_after_step_3%20%3D%20per_voter%20%20%23%20Steps%202%20and%203%20put%20both%20copies%20on%20disk%0A%20%20%20%20_destatis%2C%20_election%20%3D%20recipe.compliance.sources%0A%20%20%20%20%23%20LAND_LOCATOR%20names%20the%20same%20table%20and%20year%20as%20the%20recipe.%0A%20%20%20%20_destatis_copy%20%3D%20DestatisReader.retrieval(LAND_LOCATOR)%0A%20%20%20%20_election_copy%20%3D%20BundeswahlleiterinReader.retrieval(_election.dataset_uri)%0A%20%20%20%20_destatis_yours%20%3D%20(%0A%20%20%20%20%20%20%20%20f%22you%20on%20%7B_destatis_copy.retrieved_at%3A%25Y-%25m-%25d%7D%22%20if%20_destatis_copy%20else%20%22your%20copy%20is%20no%20longer%20in%20the%20cache%22%0A%20%20%20%20)%0A%20%20%20%20if%20_election_copy%20is%20None%3A%0A%20%20%20%20%20%20%20%20_election_yours%2C%20_same%20%3D%20%22your%20copy%20is%20no%20longer%20in%20the%20cache%22%2C%20%22nothing%20to%20compare%22%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20_election_yours%20%3D%20f%22you%20on%20%7B_election_copy.retrieved_at%3A%25Y-%25m-%25d%7D%22%0A%20%20%20%20%20%20%20%20_same%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22the%20same%20file%22%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20_election_copy.sha256%20%3D%3D%20_election.sha256%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22a%20different%20file%3A%20it%20changed%20between%20the%20two%20downloads%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20-%20**%7B_destatis.attribution%7D**%2C%20license%20%60%7B_destatis.license%7D%60%2C%20%7B_destatis.dataset_uri%7D.%20The%20recipe's%20author%0A%20%20%20%20%20%20downloaded%20it%20on%20%7B_destatis.retrieved_at%3A%25Y-%25m-%25d%7D%2C%20%7B_destatis_yours%7D.%20Its%20checksum%20cannot%20be%20compared%3A%0A%20%20%20%20%20%20GENESIS%20packs%20every%20answer%20into%20a%20new%20zip%20archive%20whose%20inner%20file%20name%20carries%20the%20time%20of%20the%0A%20%20%20%20%20%20request%2C%20so%20the%20checksum%20changes%20on%20every%20download%2C%20even%20when%20no%20number%20does.%20Changes%20recorded%20in%20the%0A%20%20%20%20%20%20recipe%3A%20%7B%22%3B%20%22.join(_destatis.modifications)%7D.%0A%20%20%20%20-%20**%7B_election.attribution%7D**%2C%20license%20%60%7B_election.license%7D%60%2C%20%7B_election.dataset_uri%7D.%20The%20recipe's%20author%0A%20%20%20%20%20%20downloaded%20it%20on%20%7B_election.retrieved_at%3A%25Y-%25m-%25d%7D%2C%20%7B_election_yours%7D.%20The%0A%20%20%20%20%20%20checksums%20say%3A%20%7B_same%7D.%20Changes%20recorded%20in%20the%20recipe%3A%20%7B%22%3B%20%22.join(_election.modifications)%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%20Both%20sources%20publish%20under%20the%20%5BData%20License%20Germany%2C%20attribution%2C%20version%202.0%5D(https%3A%2F%2Fwww.govdata.de%2Fdl-de%2Fby-2-0)%0A%20%20%20%20(%60DL-DE-BY-2.0%60)%3A%20you%20may%20reuse%20the%20data%20if%20you%20name%20the%20source%2C%20link%20the%20license%20and%20the%20data%2C%20and%20say%0A%20%20%20%20what%20you%20changed.%20The%20readers'%20changes%20are%20recorded%20above.%20In%20plain%20words%3A%20*ffcsv*%20is%20the%20CSV%20format%0A%20%20%20%20GENESIS%20delivers%2C%20its%20reference%20date%20(*Stichtag*)%20became%20a%20year%2C%20a%20%60-%60%20sign%20became%200%20with%20the%20sign%20kept%0A%20%20%20%20in%20%60value_marker%60%2C%20and%20the%20three%20header%20rows%20of%20the%20election%20file%20became%20one%20column%20name%20each.%20This%0A%20%20%20%20tutorial%20changed%20more%3A%20it%20kept%20only%20the%2016%20Land%20rows%20of%20the%20election%20file%20and%20divided%20the%20population%20by%0A%20%20%20%20the%20eligible%20voters.%0A%0A%20%20%20%20%23%23%20Next%0A%0A%20%20%20%20%5BTutorial%206%5D(https%3A%2F%2Fgithub.com%2Fmloda-ai%2Fmloda-plugin-govdata%2Fblob%2Fmain%2Ftutorials%2F06_a_new_election.py)%0A%20%20%20%20reads%20four%20Berlin%20elections%20with%20one%20set%20of%20reader%20options.%0A%20%20%20%20%5BRecipes%5D(https%3A%2F%2Fgithub.com%2Fmloda-ai%2Fmloda-plugin-govdata%2Fblob%2Fmain%2Fdocs%2Frecipes.md)%20describes%20the%20file%0A%20%20%20%20format%2C%20every%20shipped%20recipe%20and%20how%20each%20one%20is%20checked%20against%20its%20sources.%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
daac0a311a18bbe653dc4a38003e281a