Package: datenguidepy
Free software: MIT licenseDocumentation:https://datenguidepy.readthedocs.io/The package provides easy access to German publicly availableregional statistics.
It does so by providing a wrapper for theGraphQL API of the Datenguide project.FeaturesOverview of available statistics and regions:The package provides DataFrames with the available statistics and regions, which
can be queried by the user without having to refer to expert knowledge on regional
statistics or the documentation of the underlying GraphQL APIBuild and Execute Queries:The package provides the user an object oriented interface to build queries that
fetch certain statistics and return the results as a pandas DataFrame for
further analysis.Automatic inclusion of relevant meta dataQueries automatically retrieve some meta data along with the actual data
to give the user more convenient access to the statistics without having to worry
about too many technichal detailsFull fidelity dataThe package provides full fidelity data access to the datenguide API.
This allows all use cases to use precicely the data that they need
if it is available. It also means that most data cleaning has to be done
by the user.Quick StartInstallTo use the package install the package (command line):pipinstalldatenguidepyMinimal exampleTo see the package work and obtain a DataFrame containing
some statistics, the followin constitutes a minimal example.fromdatenguidepyimportQueryq=Query.region('01')q.add_field('BEV001')result_df=q.results()Complex examplesThese examples is intendend to illustrate many
of the package’s features at the same time. The
idea is to give an impression of some of the possibilities.
A more detailed explanation of the functionality can be found
in the the rest of the documentation.q=Query.region(['02','11'])stat=q.add_field('BEVSTD')stat.add_args({'year':[2011,2012]})stat2=q.add_field('AI1601')stat2.add_args({'year':[2011,2012]})q.results(verbose_statistics=True,add_units=True,).iloc[:,:7]idnameyearVerfügbares Einkommen je Einwohner (AI1601)AI1601_unitBevölkerungsstand (BEVSTD)BEVSTD_unit002Hamburg201122695EUR1718187Anzahl102Hamburg201222971EUR1734272Anzahl011Berlin201118183EUR3326002Anzahl111Berlin201218380EUR3375222Anzahlq=Query.region('11')stat=q.add_field('BEVSTD')stat.add_args({'GES':'GESW','statistics':'R12411','NAT':'ALL','year':[1995,1996]})stat.add_field('GES')stat.add_field('NAT')q.results(verbose_enums=True).iloc[:,:6]idnameGESNATyearBEVSTD011BerlinweiblichAusländer(innen)1995191378111BerlinweiblichDeutsche19951605762211BerlinweiblichGesamt19951797140311BerlinweiblichDeutsche19961590407411BerlinweiblichAusländer(innen)1996195301511BerlinweiblichGesamt19961785708Get information on fields and meta dataGet information on region ids# from datenguidepy import get_regionsget_regions()Use pandasquery()functionality to get specific regions. E.g., if you want to get all IDs on “Bundeländer” use.
For more information on “nuts” levels seeWikipedia.get_regions().query("level == 'nuts1'")Get information on statistic shortnames#  from datenguidepy import get_statisticsget_statistics()# return statistical descriptions in Englishget_statistics(target_language='en')Get information on single fieldsYou can further information about description, possible arguments, fields and enum values on a field you added to a query.q=Query.region("01")stat=q.add_field("BEV001")stat.get_info()Further informationFor detailed examples see the notebooks within theuse_casefolder.For a detailed documentation of all statistics and fields see the Datenguide API.CreditsAll this builds on the great work ofDatenguideand their GraphQL APIdatenguide/datenguide-apiThe data is retrieved via the Datenguide API from the “Statistische Ämter des Bundes und der Länder”.
Data being used via this package has to becredited according to the “Datenlizenz Deutschland – Namensnennung – Version 2.0”.This package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2019-10-07)First release on PyPI.0.1.1 (2019-10-09)Cleanup of the first release regarding naming, authors and docs.0.2.0 (2020-11-30)Added functionality to use meta data for displaying descriptive statistics names and enum values0.2.1 (2020-05-17)Added functionality to display the units of a statistic along with the numerical value.Internally split the meta data extraction into technical meta data and meta data about the statistics. Implemented new defaults for the statistics meta data in order to account for changes in the datenguide API.0.2.2 (2020-05-24)Fixed a critical bug in the package data perventing the pypi version to essentially stop working completely.Fixed a bug related to incorrectly displayed version number of the package.0.3.0 (2020-06-24)renamed get_all_regions to get_regions in accordance with get_statisticschanged the index column name of the DataFrame returnd by all_regions from id to region_idmade the statstics column name the index in the DataFrame returned by get_statistics and renamed it to statisticadded functionality to obtain a stored auto-translated version of the get_statistics descriptions (default is German, now machine translation is available in English)introduced a new helper function get_availability_summary containing a (pre-calculated) summary of available data for region_id, statistic pairs down to nut3 level.0.3.1 (2020-07-14)Introduced a better error messages for queries that are run without a statisticBug fixes related to enums and auto join functionality0.4.0 (2021-01-23)Introduced better error messages in case of invalid regionsIntroduced duplicate removal as an option for standard query results
* New default is to remove duplicates but can be turned of with an argument
* Auto-joining of multiple statistics should work better now as duplicates are removed before the joining.
* Purpouse is only to remove duplicates that that may exist for technichal API reasons. The Purpouse is not to filter the data for content.
* Rows are only counted as duplaces if everything, including the data source is identical0.4.1 (2021-08-01)Bugfixe