the-datagarden 1.2.1__tar.gz → 1.2.3__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. the_datagarden-1.2.3/PKG-INFO +253 -0
  2. the_datagarden-1.2.3/README.rst +214 -0
  3. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/pyproject.toml +3 -3
  4. the_datagarden-1.2.3/src/the_datagarden.egg-info/PKG-INFO +253 -0
  5. the_datagarden-1.2.1/PKG-INFO +0 -137
  6. the_datagarden-1.2.1/README.rst +0 -98
  7. the_datagarden-1.2.1/src/the_datagarden.egg-info/PKG-INFO +0 -137
  8. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/setup.cfg +0 -0
  9. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/__init__.py +0 -0
  10. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/abc/__init__.py +0 -0
  11. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/abc/api.py +0 -0
  12. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/abc/authentication.py +0 -0
  13. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/__init__.py +0 -0
  14. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/authentication/__init__.py +0 -0
  15. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/authentication/credentials/__init__.py +0 -0
  16. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/authentication/environment/__init__.py +0 -0
  17. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/authentication/settings.py +0 -0
  18. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/base/__init__.py +0 -0
  19. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/regions/__init__.py +0 -0
  20. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/regions/base/__init__.py +0 -0
  21. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/regions/base/settings.py +0 -0
  22. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/regions/continent.py +0 -0
  23. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/api/regions/country.py +0 -0
  24. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/cli.py +0 -0
  25. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/models/__init__.py +0 -0
  26. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/models/geojson.py +0 -0
  27. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/models/regional_data.py +0 -0
  28. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden/version.py +0 -0
  29. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden.egg-info/SOURCES.txt +0 -0
  30. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden.egg-info/dependency_links.txt +0 -0
  31. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden.egg-info/entry_points.txt +0 -0
  32. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden.egg-info/requires.txt +0 -0
  33. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/src/the_datagarden.egg-info/top_level.txt +0 -0
  34. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/tests/test_cli.py +0 -0
  35. {the_datagarden-1.2.1 → the_datagarden-1.2.3}/tests/test_the_datagarden_imports.py +0 -0
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.1
2
+ Name: the-datagarden
3
+ Version: 1.2.3
4
+ Summary: Public data made easy.
5
+ Author-email: Maarten de Ruyter <info@the-datagarden.io>
6
+ License: MIT
7
+ Project-URL: Read the Docs, https://dg-the-datagarden.readthedocs.io/en/stable/
8
+ Project-URL: The-DataGarden, https://www.the-datagarden.io/
9
+ Project-URL: API documentation, https://www.the-datagarden.io/api-docs
10
+ Project-URL: Source, https://github.com/the-datagarden/the-datagarden
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Development Status :: 4 - Beta
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Intended Audience :: Financial and Insurance Industry
21
+ Classifier: Intended Audience :: Science/Research
22
+ Classifier: Intended Audience :: Healthcare Industry
23
+ Classifier: Topic :: Scientific/Engineering :: GIS
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
26
+ Classifier: Topic :: Scientific/Engineering :: Visualization
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: Utilities
29
+ Requires-Python: >=3.10
30
+ Description-Content-Type: text/x-rst
31
+ Requires-Dist: click>=8.1.7
32
+ Requires-Dist: pandas>=2.2.3
33
+ Requires-Dist: polars>=1.15.0
34
+ Requires-Dist: pydantic>=2.9.2
35
+ Requires-Dist: pyjwt>=2.10.0
36
+ Requires-Dist: python-decouple>=3.8
37
+ Requires-Dist: requests>=2.32.3
38
+ Requires-Dist: the-datagarden-models>=1.6.3
39
+
40
+ ==================
41
+ the-datagarden SDK
42
+ ==================
43
+
44
+ The-datagarden package is a Python SDK built on top of The-DataGarden API. The SDK provides easy access to continent and country regional hierarchies,
45
+ as well as public data related to these regions. All data from The-DataGarden API is stored in normalized datamodels like ``Demographics``, ``Health``
46
+ or ``Economics``. This allows you as a data professional to create value from this data without having to worry about the (varying) data structure and
47
+ api's from the sources.
48
+
49
+ Additionally, The-DataGarden API also provides country and regional GeoJSONs. The SDK makes is easy for you to combine public data abd you own data and merge them into
50
+ geosjon Feature collections, making geographic visualisation easy.
51
+
52
+
53
+ The-DataGarden SDK main use case
54
+ --------------------------------
55
+ The SDK is designed to make it easy to access and work with the DataGarden data. After initializing the SDK you simply
56
+ retrieve data for a specific continent, country or subregion by calling the appropriate datamodel.
57
+
58
+ .. code-block:: python
59
+
60
+ # initialize a country object and retrieve the demographics attribute
61
+ >>> nl = the_datagarden_api.netherlands # or nl = the_datagarden_api.NL
62
+ >>> nl_demographics = nl.demographics()
63
+ TheDataGardenRegionalDataModel : Demographics : (count=5)
64
+
65
+ In this example the `nl_demographics` object holds 5 records. Each record contains demographic data for the Netherlands for a specific
66
+ period and period type combination. The data can be made accessible in a tabular format by converting the object to a pandas or polars dataframe.
67
+
68
+ .. code-block:: python
69
+
70
+ # convert demographics data to a polars dataframe
71
+ >>> dataframe = nl_demographics.full_model_to_polars()
72
+ >>> print(dataframe["period", "source_name", "data_model_name", "population.total", "population.total_male", "population.total_female"])
73
+
74
+ .. code-block:: text
75
+
76
+ ┌───────────────┬────────────┬─────────────────┬──────────────────┬───────────────────────┬─────────────────────────┐
77
+ │ period ┆ source_name┆ data_model_name ┆ population.total ┆ population.total_male ┆ population.total_female │
78
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
79
+ │ str ┆ str ┆ str ┆ f64 ┆ f64 ┆ f64 │
80
+ ╞═══════════════╪════════════╪═════════════════╪══════════════════╪═══════════════════════╪═════════════════════════╡
81
+ │ 2022-01-01T0Z ┆ Eurostat ┆ Demographics ┆ null ┆ 8.745468e6 ┆ 8.845204e6 │
82
+ │ 2022-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.7789347e7 ┆ 8.890013e6 ┆ 9.014408e6 │
83
+ │ 2023-01-01T0Z ┆ Eurostat ┆ Demographics ┆ null ┆ 8.850309e6 ┆ 8.960982e6 │
84
+ │ 2023-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.8019495e7 ┆ 8.986255e6 ┆ 9.106269e6 │
85
+ │ 2024-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.8165554e7 ┆ 9.055978e6 ┆ 9.172763e6 │
86
+ └───────────────┴────────────┴─────────────────┴──────────────────┴───────────────────────┴─────────────────────────┘
87
+
88
+ The demographics model holds lots of submodels and attributes. In this example only a limited number of attributes are listed
89
+ as the dataframe is way too large to display. For all models and their details see the model data documentation at
90
+ `The DataGarden Data Documentation <https://www.the-datagarden.io/data-docs>`_.
91
+
92
+ Getting started with the SDK
93
+ ----------------------------
94
+ You can start using the SDK out of the box by simply instatiating the TheDataGardenAPI object:
95
+
96
+ .. code-block:: python
97
+
98
+ # Starting with the datagarden API
99
+ >>> from the-datagarden import TheDataGardenAPI
100
+ >>> the_datagarden_api = TheDataGardenAPI()
101
+
102
+ .. code-block:: console
103
+
104
+ Welcome to The Data Garden API.
105
+
106
+ You can start using the API with an account from The-Datagarden.io.
107
+ Please provide your credentials or create a new account.
108
+ Check www.the-datagarden.io for more information.
109
+
110
+ Do you want to (1) create a new account or (2) provide existing credentials? Enter 1 or 2:
111
+
112
+
113
+ simply select 1 to create a new account.
114
+
115
+ .. code-block:: console
116
+
117
+ Enrolling in The Data Garden API...
118
+
119
+ Enter your email: <your-email>
120
+ Enter your password: <your-password>
121
+ Confirm your password: <your-password>
122
+
123
+ Successfully enrolled in The Data Garden API.
124
+ Initializing : TheDatagardenEnvironment
125
+ At: https://www.the-datagarden.io/
126
+
127
+ If you already have an account at the-datagarden.io, you can either select option 2 or directly provide your credentials
128
+ when creating the TheDataGardenAPI object:
129
+
130
+ .. code-block:: python
131
+
132
+ # Retrieve a country object from the datagarden API
133
+ >>> from the-datagarden import TheDataGardenAPI
134
+ >>> the_datagarden_api = TheDataGardenAPI(email='your-email@example.com', password='your-password')
135
+
136
+ .. code-block:: console
137
+
138
+ Initializing : TheDatagardenEnvironment
139
+ At: https://www.the-datagarden.io/
140
+
141
+ A 3rd way to initialize the SDK is adding your credentials to the ``.env`` file.
142
+
143
+
144
+ Getting your first data from The-DataGarden API
145
+ -----------------------------------------------
146
+ Now that you have initialized the SDK, you can start retrieving data from The-DataGarden API.
147
+ For example, you can retrieve the demographics data for the Netherlands:
148
+
149
+ .. code-block:: python
150
+
151
+ # initialize a country object and retrieve the demographics attribute
152
+ >>> nl = the_datagarden_api.netherlands
153
+ >>> nl_demographics = nl.demographics
154
+ TheDataGardenRegionalDataModel : Demographics : (count=0)
155
+
156
+ This creates a country object ``nl`` for the Netherlands, which serves as your gateway to all Netherlands-related
157
+ data and its regional subdivisions.
158
+
159
+ In this getting started section we will work with a demographics object retrieved from the `nl` country object.
160
+ As shown in the example, the ``nl_demographics`` object can be retrieved by simply calling the `demographics`
161
+ attribute on the `nl` country object
162
+
163
+ The `nl_demographics` object starts empty (count=0). To populate it with data, simply call it as a function:
164
+
165
+ .. code-block:: python
166
+
167
+ # Calling the demographics attribute will populate it with demographics data from the API
168
+ >>> nl_demographics()
169
+ >>> nl_demographics
170
+ TheDataGardenRegionalDataModel : Demographics : (count=5)
171
+
172
+ When called without parameters, the API returns data using default settings, which in this case yields 5 records.
173
+ You can customize your data retrieval by specifying parameters such as time periods, period types, and data sources.
174
+
175
+
176
+ The DataGarden Regional DataModel
177
+ ---------------------------------
178
+ When you retrieve data like ``nl_demographics``, you're working with a ``TheDataGardenRegionalDataModel`` object. This object acts as a container that holds:
179
+
180
+ 1. A collection of ``TheDataGardenRegionalDataRecord`` objects
181
+ 2. Metadata about the records (region, time period, data source, etc.)
182
+
183
+ You can easily transform this data into pandas or polars DataFrames for analysis. Here's an example showing population data for the Netherlands:
184
+
185
+ .. code-block:: python
186
+
187
+ >>> nl = the_datagarden_api.netherlands
188
+ >>> nl_demographics = nl.demographics(period_from="2010-01-01", source="united nations")
189
+ >>> # Convert to DataFrame, mapping 'population.total' to column name 'pop_count'
190
+ >>> df = nl_demographics.to_polars({"pop_count": "population.total"}) # or to_pandas(...)
191
+ >>> df["name", "source_name", "period", "data_model_name", "total"] # for readability only a limited number of columns are displayed
192
+ ┌─────────────┬────────────────┬─────────────────┬─────────────────┬─────────────┐
193
+ │ name ┆ source_name ┆ period ┆ data_model_name ┆ pop_count │
194
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
195
+ │ str ┆ str ┆ str ┆ str ┆ f64 │
196
+ ╞═════════════╪════════════════╪═════════════════╪═════════════════╪═════════════╡
197
+ │ Netherlands ┆ United Nations ┆ 2010-01-010:00Z ┆ Demographics ┆ 1.6729801e7 │
198
+ │ Netherlands ┆ United Nations ┆ 2011-01-010:00Z ┆ Demographics ┆ 1.6812669e7 │
199
+ │ … ┆ … ┆ … ┆ … ┆ … │
200
+ │ Netherlands ┆ United Nations ┆ 2023-01-010:00Z ┆ Demographics ┆ 1.8019495e7 │
201
+ │ Netherlands ┆ United Nations ┆ 2024-01-010:00Z ┆ Demographics ┆ 1.8165554e7 │
202
+ └─────────────┴────────────────┴─────────────────┴─────────────────┴─────────────┘
203
+
204
+ Each time you call the ``nl_demographics`` object with different parameters,
205
+ new demographic records for the specified subregions, periods, and/or sources are added to the existing ``nl_demographics`` object.
206
+ After you've gathered all the records you need, you can convert the entire collection into a dataframe for further analysis.
207
+
208
+
209
+ Retrieving GeoJSON data
210
+ -----------------------
211
+ Retrieving the GeoJSON for the Netherlands and its provinces is straightforward as well:
212
+
213
+ .. code-block:: python
214
+
215
+ >>> nl_geojson = nl.geojsons()
216
+ >>> nl_geojson
217
+ TheDataGardenRegionGeoJSONModel : GeoJSON : (count=1)
218
+ >>> nl_geojson(region_level=2) # Retrieve GeoJSON for 2nd regional level (provinces)
219
+ TheDataGardenRegionGeoJSONModel : GeoJSON : (count=13) # 12 provinces + 1 country
220
+ >>> df = nl_geojson.to_polars()
221
+ >>> df["name", "region_type", "local_region_code", "region_level", "feature"]
222
+ ┌───────────────┬─────────────┬───────────────┬──────────────┬────────────────────────┐
223
+ │ name ┆ region_type ┆ local_region_c┆ region_level ┆ feature │
224
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
225
+ │ str ┆ str ┆ str ┆ i64 ┆ struct[3] │
226
+ ╞═══════════════╪═════════════╪═══════════════╪══════════════╪════════════════════════╡
227
+ │ Netherlands ┆ country ┆ 528 ┆ 0 ┆ {"Feature",{"Netherland│
228
+ │ Drenthe ┆ province ┆ NL13 ┆ 2 ┆ {"Feature",{"Drenthe",2│
229
+ │ … ┆ … ┆ … ┆ … ┆ … │
230
+ │ Zuid-Holland ┆ province ┆ NL33 ┆ 2 ┆ {"Feature",{"Zuid-Holla│
231
+ └───────────────┴─────────────┴───────────────┴──────────────┴────────────────────────┘
232
+
233
+ For readability, the output only a limited number of dataframe columns are displayed.
234
+ Attributes in both the demographics and geojson dataframes are available to connect the geojson to
235
+ the demographics data. This allows you quickly make data sets that contain both demographics and geojson data
236
+ for further analysis or visualisation in map applications.
237
+
238
+
239
+ Read more
240
+ ---------
241
+
242
+ * `The DataGarden Website <https://www.the-datagarden.io>`_
243
+ * `API Documentation <https://www.the-datagarden.io/api-docs>`_
244
+ * `The Datagarden Models <https://www.the-datagarden.io/data-docs>`_
245
+ * `GitHub Repository <https://github.com/MaartendeRuyter/dg-the-datagarden>`_
246
+
247
+
248
+ Access to The DataGarden API
249
+ ----------------------------
250
+ To use the DataGarden SDK, you need access to the The DataGarden API. Simply register for free at https://www.the-datagarden.io
251
+ and you will have an inital free access account to the API with access to country and continent data.
252
+
253
+ Visit https://www.the-datagarden.io to register for free.
@@ -0,0 +1,214 @@
1
+ ==================
2
+ the-datagarden SDK
3
+ ==================
4
+
5
+ The-datagarden package is a Python SDK built on top of The-DataGarden API. The SDK provides easy access to continent and country regional hierarchies,
6
+ as well as public data related to these regions. All data from The-DataGarden API is stored in normalized datamodels like ``Demographics``, ``Health``
7
+ or ``Economics``. This allows you as a data professional to create value from this data without having to worry about the (varying) data structure and
8
+ api's from the sources.
9
+
10
+ Additionally, The-DataGarden API also provides country and regional GeoJSONs. The SDK makes is easy for you to combine public data abd you own data and merge them into
11
+ geosjon Feature collections, making geographic visualisation easy.
12
+
13
+
14
+ The-DataGarden SDK main use case
15
+ --------------------------------
16
+ The SDK is designed to make it easy to access and work with the DataGarden data. After initializing the SDK you simply
17
+ retrieve data for a specific continent, country or subregion by calling the appropriate datamodel.
18
+
19
+ .. code-block:: python
20
+
21
+ # initialize a country object and retrieve the demographics attribute
22
+ >>> nl = the_datagarden_api.netherlands # or nl = the_datagarden_api.NL
23
+ >>> nl_demographics = nl.demographics()
24
+ TheDataGardenRegionalDataModel : Demographics : (count=5)
25
+
26
+ In this example the `nl_demographics` object holds 5 records. Each record contains demographic data for the Netherlands for a specific
27
+ period and period type combination. The data can be made accessible in a tabular format by converting the object to a pandas or polars dataframe.
28
+
29
+ .. code-block:: python
30
+
31
+ # convert demographics data to a polars dataframe
32
+ >>> dataframe = nl_demographics.full_model_to_polars()
33
+ >>> print(dataframe["period", "source_name", "data_model_name", "population.total", "population.total_male", "population.total_female"])
34
+
35
+ .. code-block:: text
36
+
37
+ ┌───────────────┬────────────┬─────────────────┬──────────────────┬───────────────────────┬─────────────────────────┐
38
+ │ period ┆ source_name┆ data_model_name ┆ population.total ┆ population.total_male ┆ population.total_female │
39
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
40
+ │ str ┆ str ┆ str ┆ f64 ┆ f64 ┆ f64 │
41
+ ╞═══════════════╪════════════╪═════════════════╪══════════════════╪═══════════════════════╪═════════════════════════╡
42
+ │ 2022-01-01T0Z ┆ Eurostat ┆ Demographics ┆ null ┆ 8.745468e6 ┆ 8.845204e6 │
43
+ │ 2022-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.7789347e7 ┆ 8.890013e6 ┆ 9.014408e6 │
44
+ │ 2023-01-01T0Z ┆ Eurostat ┆ Demographics ┆ null ┆ 8.850309e6 ┆ 8.960982e6 │
45
+ │ 2023-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.8019495e7 ┆ 8.986255e6 ┆ 9.106269e6 │
46
+ │ 2024-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.8165554e7 ┆ 9.055978e6 ┆ 9.172763e6 │
47
+ └───────────────┴────────────┴─────────────────┴──────────────────┴───────────────────────┴─────────────────────────┘
48
+
49
+ The demographics model holds lots of submodels and attributes. In this example only a limited number of attributes are listed
50
+ as the dataframe is way too large to display. For all models and their details see the model data documentation at
51
+ `The DataGarden Data Documentation <https://www.the-datagarden.io/data-docs>`_.
52
+
53
+ Getting started with the SDK
54
+ ----------------------------
55
+ You can start using the SDK out of the box by simply instatiating the TheDataGardenAPI object:
56
+
57
+ .. code-block:: python
58
+
59
+ # Starting with the datagarden API
60
+ >>> from the-datagarden import TheDataGardenAPI
61
+ >>> the_datagarden_api = TheDataGardenAPI()
62
+
63
+ .. code-block:: console
64
+
65
+ Welcome to The Data Garden API.
66
+
67
+ You can start using the API with an account from The-Datagarden.io.
68
+ Please provide your credentials or create a new account.
69
+ Check www.the-datagarden.io for more information.
70
+
71
+ Do you want to (1) create a new account or (2) provide existing credentials? Enter 1 or 2:
72
+
73
+
74
+ simply select 1 to create a new account.
75
+
76
+ .. code-block:: console
77
+
78
+ Enrolling in The Data Garden API...
79
+
80
+ Enter your email: <your-email>
81
+ Enter your password: <your-password>
82
+ Confirm your password: <your-password>
83
+
84
+ Successfully enrolled in The Data Garden API.
85
+ Initializing : TheDatagardenEnvironment
86
+ At: https://www.the-datagarden.io/
87
+
88
+ If you already have an account at the-datagarden.io, you can either select option 2 or directly provide your credentials
89
+ when creating the TheDataGardenAPI object:
90
+
91
+ .. code-block:: python
92
+
93
+ # Retrieve a country object from the datagarden API
94
+ >>> from the-datagarden import TheDataGardenAPI
95
+ >>> the_datagarden_api = TheDataGardenAPI(email='your-email@example.com', password='your-password')
96
+
97
+ .. code-block:: console
98
+
99
+ Initializing : TheDatagardenEnvironment
100
+ At: https://www.the-datagarden.io/
101
+
102
+ A 3rd way to initialize the SDK is adding your credentials to the ``.env`` file.
103
+
104
+
105
+ Getting your first data from The-DataGarden API
106
+ -----------------------------------------------
107
+ Now that you have initialized the SDK, you can start retrieving data from The-DataGarden API.
108
+ For example, you can retrieve the demographics data for the Netherlands:
109
+
110
+ .. code-block:: python
111
+
112
+ # initialize a country object and retrieve the demographics attribute
113
+ >>> nl = the_datagarden_api.netherlands
114
+ >>> nl_demographics = nl.demographics
115
+ TheDataGardenRegionalDataModel : Demographics : (count=0)
116
+
117
+ This creates a country object ``nl`` for the Netherlands, which serves as your gateway to all Netherlands-related
118
+ data and its regional subdivisions.
119
+
120
+ In this getting started section we will work with a demographics object retrieved from the `nl` country object.
121
+ As shown in the example, the ``nl_demographics`` object can be retrieved by simply calling the `demographics`
122
+ attribute on the `nl` country object
123
+
124
+ The `nl_demographics` object starts empty (count=0). To populate it with data, simply call it as a function:
125
+
126
+ .. code-block:: python
127
+
128
+ # Calling the demographics attribute will populate it with demographics data from the API
129
+ >>> nl_demographics()
130
+ >>> nl_demographics
131
+ TheDataGardenRegionalDataModel : Demographics : (count=5)
132
+
133
+ When called without parameters, the API returns data using default settings, which in this case yields 5 records.
134
+ You can customize your data retrieval by specifying parameters such as time periods, period types, and data sources.
135
+
136
+
137
+ The DataGarden Regional DataModel
138
+ ---------------------------------
139
+ When you retrieve data like ``nl_demographics``, you're working with a ``TheDataGardenRegionalDataModel`` object. This object acts as a container that holds:
140
+
141
+ 1. A collection of ``TheDataGardenRegionalDataRecord`` objects
142
+ 2. Metadata about the records (region, time period, data source, etc.)
143
+
144
+ You can easily transform this data into pandas or polars DataFrames for analysis. Here's an example showing population data for the Netherlands:
145
+
146
+ .. code-block:: python
147
+
148
+ >>> nl = the_datagarden_api.netherlands
149
+ >>> nl_demographics = nl.demographics(period_from="2010-01-01", source="united nations")
150
+ >>> # Convert to DataFrame, mapping 'population.total' to column name 'pop_count'
151
+ >>> df = nl_demographics.to_polars({"pop_count": "population.total"}) # or to_pandas(...)
152
+ >>> df["name", "source_name", "period", "data_model_name", "total"] # for readability only a limited number of columns are displayed
153
+ ┌─────────────┬────────────────┬─────────────────┬─────────────────┬─────────────┐
154
+ │ name ┆ source_name ┆ period ┆ data_model_name ┆ pop_count │
155
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
156
+ │ str ┆ str ┆ str ┆ str ┆ f64 │
157
+ ╞═════════════╪════════════════╪═════════════════╪═════════════════╪═════════════╡
158
+ │ Netherlands ┆ United Nations ┆ 2010-01-010:00Z ┆ Demographics ┆ 1.6729801e7 │
159
+ │ Netherlands ┆ United Nations ┆ 2011-01-010:00Z ┆ Demographics ┆ 1.6812669e7 │
160
+ │ … ┆ … ┆ … ┆ … ┆ … │
161
+ │ Netherlands ┆ United Nations ┆ 2023-01-010:00Z ┆ Demographics ┆ 1.8019495e7 │
162
+ │ Netherlands ┆ United Nations ┆ 2024-01-010:00Z ┆ Demographics ┆ 1.8165554e7 │
163
+ └─────────────┴────────────────┴─────────────────┴─────────────────┴─────────────┘
164
+
165
+ Each time you call the ``nl_demographics`` object with different parameters,
166
+ new demographic records for the specified subregions, periods, and/or sources are added to the existing ``nl_demographics`` object.
167
+ After you've gathered all the records you need, you can convert the entire collection into a dataframe for further analysis.
168
+
169
+
170
+ Retrieving GeoJSON data
171
+ -----------------------
172
+ Retrieving the GeoJSON for the Netherlands and its provinces is straightforward as well:
173
+
174
+ .. code-block:: python
175
+
176
+ >>> nl_geojson = nl.geojsons()
177
+ >>> nl_geojson
178
+ TheDataGardenRegionGeoJSONModel : GeoJSON : (count=1)
179
+ >>> nl_geojson(region_level=2) # Retrieve GeoJSON for 2nd regional level (provinces)
180
+ TheDataGardenRegionGeoJSONModel : GeoJSON : (count=13) # 12 provinces + 1 country
181
+ >>> df = nl_geojson.to_polars()
182
+ >>> df["name", "region_type", "local_region_code", "region_level", "feature"]
183
+ ┌───────────────┬─────────────┬───────────────┬──────────────┬────────────────────────┐
184
+ │ name ┆ region_type ┆ local_region_c┆ region_level ┆ feature │
185
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
186
+ │ str ┆ str ┆ str ┆ i64 ┆ struct[3] │
187
+ ╞═══════════════╪═════════════╪═══════════════╪══════════════╪════════════════════════╡
188
+ │ Netherlands ┆ country ┆ 528 ┆ 0 ┆ {"Feature",{"Netherland│
189
+ │ Drenthe ┆ province ┆ NL13 ┆ 2 ┆ {"Feature",{"Drenthe",2│
190
+ │ … ┆ … ┆ … ┆ … ┆ … │
191
+ │ Zuid-Holland ┆ province ┆ NL33 ┆ 2 ┆ {"Feature",{"Zuid-Holla│
192
+ └───────────────┴─────────────┴───────────────┴──────────────┴────────────────────────┘
193
+
194
+ For readability, the output only a limited number of dataframe columns are displayed.
195
+ Attributes in both the demographics and geojson dataframes are available to connect the geojson to
196
+ the demographics data. This allows you quickly make data sets that contain both demographics and geojson data
197
+ for further analysis or visualisation in map applications.
198
+
199
+
200
+ Read more
201
+ ---------
202
+
203
+ * `The DataGarden Website <https://www.the-datagarden.io>`_
204
+ * `API Documentation <https://www.the-datagarden.io/api-docs>`_
205
+ * `The Datagarden Models <https://www.the-datagarden.io/data-docs>`_
206
+ * `GitHub Repository <https://github.com/MaartendeRuyter/dg-the-datagarden>`_
207
+
208
+
209
+ Access to The DataGarden API
210
+ ----------------------------
211
+ To use the DataGarden SDK, you need access to the The DataGarden API. Simply register for free at https://www.the-datagarden.io
212
+ and you will have an inital free access account to the API with access to country and continent data.
213
+
214
+ Visit https://www.the-datagarden.io to register for free.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "the-datagarden"
3
- version = "1.2.1"
3
+ version = "1.2.3"
4
4
  description = "Public data made easy."
5
5
  readme = "README.rst"
6
6
  requires-python = ">=3.10"
@@ -54,9 +54,9 @@ dev = [
54
54
  the-datagarden = "the_datagarden.cli:main"
55
55
 
56
56
  [project.urls]
57
- "Read the Docs" = "https://the-datagarden.readthedocs.io/"
57
+ "Read the Docs" = "https://dg-the-datagarden.readthedocs.io/en/stable/"
58
58
  "The-DataGarden" = "https://www.the-datagarden.io/"
59
- "API documentation" = "https://api.the-datagarden.io/api-docs"
59
+ "API documentation" = "https://www.the-datagarden.io/api-docs"
60
60
  "Source" = "https://github.com/the-datagarden/the-datagarden"
61
61
 
62
62
 
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.1
2
+ Name: the-datagarden
3
+ Version: 1.2.3
4
+ Summary: Public data made easy.
5
+ Author-email: Maarten de Ruyter <info@the-datagarden.io>
6
+ License: MIT
7
+ Project-URL: Read the Docs, https://dg-the-datagarden.readthedocs.io/en/stable/
8
+ Project-URL: The-DataGarden, https://www.the-datagarden.io/
9
+ Project-URL: API documentation, https://www.the-datagarden.io/api-docs
10
+ Project-URL: Source, https://github.com/the-datagarden/the-datagarden
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Development Status :: 4 - Beta
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Intended Audience :: Financial and Insurance Industry
21
+ Classifier: Intended Audience :: Science/Research
22
+ Classifier: Intended Audience :: Healthcare Industry
23
+ Classifier: Topic :: Scientific/Engineering :: GIS
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
26
+ Classifier: Topic :: Scientific/Engineering :: Visualization
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: Utilities
29
+ Requires-Python: >=3.10
30
+ Description-Content-Type: text/x-rst
31
+ Requires-Dist: click>=8.1.7
32
+ Requires-Dist: pandas>=2.2.3
33
+ Requires-Dist: polars>=1.15.0
34
+ Requires-Dist: pydantic>=2.9.2
35
+ Requires-Dist: pyjwt>=2.10.0
36
+ Requires-Dist: python-decouple>=3.8
37
+ Requires-Dist: requests>=2.32.3
38
+ Requires-Dist: the-datagarden-models>=1.6.3
39
+
40
+ ==================
41
+ the-datagarden SDK
42
+ ==================
43
+
44
+ The-datagarden package is a Python SDK built on top of The-DataGarden API. The SDK provides easy access to continent and country regional hierarchies,
45
+ as well as public data related to these regions. All data from The-DataGarden API is stored in normalized datamodels like ``Demographics``, ``Health``
46
+ or ``Economics``. This allows you as a data professional to create value from this data without having to worry about the (varying) data structure and
47
+ api's from the sources.
48
+
49
+ Additionally, The-DataGarden API also provides country and regional GeoJSONs. The SDK makes is easy for you to combine public data abd you own data and merge them into
50
+ geosjon Feature collections, making geographic visualisation easy.
51
+
52
+
53
+ The-DataGarden SDK main use case
54
+ --------------------------------
55
+ The SDK is designed to make it easy to access and work with the DataGarden data. After initializing the SDK you simply
56
+ retrieve data for a specific continent, country or subregion by calling the appropriate datamodel.
57
+
58
+ .. code-block:: python
59
+
60
+ # initialize a country object and retrieve the demographics attribute
61
+ >>> nl = the_datagarden_api.netherlands # or nl = the_datagarden_api.NL
62
+ >>> nl_demographics = nl.demographics()
63
+ TheDataGardenRegionalDataModel : Demographics : (count=5)
64
+
65
+ In this example the `nl_demographics` object holds 5 records. Each record contains demographic data for the Netherlands for a specific
66
+ period and period type combination. The data can be made accessible in a tabular format by converting the object to a pandas or polars dataframe.
67
+
68
+ .. code-block:: python
69
+
70
+ # convert demographics data to a polars dataframe
71
+ >>> dataframe = nl_demographics.full_model_to_polars()
72
+ >>> print(dataframe["period", "source_name", "data_model_name", "population.total", "population.total_male", "population.total_female"])
73
+
74
+ .. code-block:: text
75
+
76
+ ┌───────────────┬────────────┬─────────────────┬──────────────────┬───────────────────────┬─────────────────────────┐
77
+ │ period ┆ source_name┆ data_model_name ┆ population.total ┆ population.total_male ┆ population.total_female │
78
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
79
+ │ str ┆ str ┆ str ┆ f64 ┆ f64 ┆ f64 │
80
+ ╞═══════════════╪════════════╪═════════════════╪══════════════════╪═══════════════════════╪═════════════════════════╡
81
+ │ 2022-01-01T0Z ┆ Eurostat ┆ Demographics ┆ null ┆ 8.745468e6 ┆ 8.845204e6 │
82
+ │ 2022-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.7789347e7 ┆ 8.890013e6 ┆ 9.014408e6 │
83
+ │ 2023-01-01T0Z ┆ Eurostat ┆ Demographics ┆ null ┆ 8.850309e6 ┆ 8.960982e6 │
84
+ │ 2023-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.8019495e7 ┆ 8.986255e6 ┆ 9.106269e6 │
85
+ │ 2024-01-01T0Z ┆ United Nat ┆ Demographics ┆ 1.8165554e7 ┆ 9.055978e6 ┆ 9.172763e6 │
86
+ └───────────────┴────────────┴─────────────────┴──────────────────┴───────────────────────┴─────────────────────────┘
87
+
88
+ The demographics model holds lots of submodels and attributes. In this example only a limited number of attributes are listed
89
+ as the dataframe is way too large to display. For all models and their details see the model data documentation at
90
+ `The DataGarden Data Documentation <https://www.the-datagarden.io/data-docs>`_.
91
+
92
+ Getting started with the SDK
93
+ ----------------------------
94
+ You can start using the SDK out of the box by simply instatiating the TheDataGardenAPI object:
95
+
96
+ .. code-block:: python
97
+
98
+ # Starting with the datagarden API
99
+ >>> from the-datagarden import TheDataGardenAPI
100
+ >>> the_datagarden_api = TheDataGardenAPI()
101
+
102
+ .. code-block:: console
103
+
104
+ Welcome to The Data Garden API.
105
+
106
+ You can start using the API with an account from The-Datagarden.io.
107
+ Please provide your credentials or create a new account.
108
+ Check www.the-datagarden.io for more information.
109
+
110
+ Do you want to (1) create a new account or (2) provide existing credentials? Enter 1 or 2:
111
+
112
+
113
+ simply select 1 to create a new account.
114
+
115
+ .. code-block:: console
116
+
117
+ Enrolling in The Data Garden API...
118
+
119
+ Enter your email: <your-email>
120
+ Enter your password: <your-password>
121
+ Confirm your password: <your-password>
122
+
123
+ Successfully enrolled in The Data Garden API.
124
+ Initializing : TheDatagardenEnvironment
125
+ At: https://www.the-datagarden.io/
126
+
127
+ If you already have an account at the-datagarden.io, you can either select option 2 or directly provide your credentials
128
+ when creating the TheDataGardenAPI object:
129
+
130
+ .. code-block:: python
131
+
132
+ # Retrieve a country object from the datagarden API
133
+ >>> from the-datagarden import TheDataGardenAPI
134
+ >>> the_datagarden_api = TheDataGardenAPI(email='your-email@example.com', password='your-password')
135
+
136
+ .. code-block:: console
137
+
138
+ Initializing : TheDatagardenEnvironment
139
+ At: https://www.the-datagarden.io/
140
+
141
+ A 3rd way to initialize the SDK is adding your credentials to the ``.env`` file.
142
+
143
+
144
+ Getting your first data from The-DataGarden API
145
+ -----------------------------------------------
146
+ Now that you have initialized the SDK, you can start retrieving data from The-DataGarden API.
147
+ For example, you can retrieve the demographics data for the Netherlands:
148
+
149
+ .. code-block:: python
150
+
151
+ # initialize a country object and retrieve the demographics attribute
152
+ >>> nl = the_datagarden_api.netherlands
153
+ >>> nl_demographics = nl.demographics
154
+ TheDataGardenRegionalDataModel : Demographics : (count=0)
155
+
156
+ This creates a country object ``nl`` for the Netherlands, which serves as your gateway to all Netherlands-related
157
+ data and its regional subdivisions.
158
+
159
+ In this getting started section we will work with a demographics object retrieved from the `nl` country object.
160
+ As shown in the example, the ``nl_demographics`` object can be retrieved by simply calling the `demographics`
161
+ attribute on the `nl` country object
162
+
163
+ The `nl_demographics` object starts empty (count=0). To populate it with data, simply call it as a function:
164
+
165
+ .. code-block:: python
166
+
167
+ # Calling the demographics attribute will populate it with demographics data from the API
168
+ >>> nl_demographics()
169
+ >>> nl_demographics
170
+ TheDataGardenRegionalDataModel : Demographics : (count=5)
171
+
172
+ When called without parameters, the API returns data using default settings, which in this case yields 5 records.
173
+ You can customize your data retrieval by specifying parameters such as time periods, period types, and data sources.
174
+
175
+
176
+ The DataGarden Regional DataModel
177
+ ---------------------------------
178
+ When you retrieve data like ``nl_demographics``, you're working with a ``TheDataGardenRegionalDataModel`` object. This object acts as a container that holds:
179
+
180
+ 1. A collection of ``TheDataGardenRegionalDataRecord`` objects
181
+ 2. Metadata about the records (region, time period, data source, etc.)
182
+
183
+ You can easily transform this data into pandas or polars DataFrames for analysis. Here's an example showing population data for the Netherlands:
184
+
185
+ .. code-block:: python
186
+
187
+ >>> nl = the_datagarden_api.netherlands
188
+ >>> nl_demographics = nl.demographics(period_from="2010-01-01", source="united nations")
189
+ >>> # Convert to DataFrame, mapping 'population.total' to column name 'pop_count'
190
+ >>> df = nl_demographics.to_polars({"pop_count": "population.total"}) # or to_pandas(...)
191
+ >>> df["name", "source_name", "period", "data_model_name", "total"] # for readability only a limited number of columns are displayed
192
+ ┌─────────────┬────────────────┬─────────────────┬─────────────────┬─────────────┐
193
+ │ name ┆ source_name ┆ period ┆ data_model_name ┆ pop_count │
194
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
195
+ │ str ┆ str ┆ str ┆ str ┆ f64 │
196
+ ╞═════════════╪════════════════╪═════════════════╪═════════════════╪═════════════╡
197
+ │ Netherlands ┆ United Nations ┆ 2010-01-010:00Z ┆ Demographics ┆ 1.6729801e7 │
198
+ │ Netherlands ┆ United Nations ┆ 2011-01-010:00Z ┆ Demographics ┆ 1.6812669e7 │
199
+ │ … ┆ … ┆ … ┆ … ┆ … │
200
+ │ Netherlands ┆ United Nations ┆ 2023-01-010:00Z ┆ Demographics ┆ 1.8019495e7 │
201
+ │ Netherlands ┆ United Nations ┆ 2024-01-010:00Z ┆ Demographics ┆ 1.8165554e7 │
202
+ └─────────────┴────────────────┴─────────────────┴─────────────────┴─────────────┘
203
+
204
+ Each time you call the ``nl_demographics`` object with different parameters,
205
+ new demographic records for the specified subregions, periods, and/or sources are added to the existing ``nl_demographics`` object.
206
+ After you've gathered all the records you need, you can convert the entire collection into a dataframe for further analysis.
207
+
208
+
209
+ Retrieving GeoJSON data
210
+ -----------------------
211
+ Retrieving the GeoJSON for the Netherlands and its provinces is straightforward as well:
212
+
213
+ .. code-block:: python
214
+
215
+ >>> nl_geojson = nl.geojsons()
216
+ >>> nl_geojson
217
+ TheDataGardenRegionGeoJSONModel : GeoJSON : (count=1)
218
+ >>> nl_geojson(region_level=2) # Retrieve GeoJSON for 2nd regional level (provinces)
219
+ TheDataGardenRegionGeoJSONModel : GeoJSON : (count=13) # 12 provinces + 1 country
220
+ >>> df = nl_geojson.to_polars()
221
+ >>> df["name", "region_type", "local_region_code", "region_level", "feature"]
222
+ ┌───────────────┬─────────────┬───────────────┬──────────────┬────────────────────────┐
223
+ │ name ┆ region_type ┆ local_region_c┆ region_level ┆ feature │
224
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
225
+ │ str ┆ str ┆ str ┆ i64 ┆ struct[3] │
226
+ ╞═══════════════╪═════════════╪═══════════════╪══════════════╪════════════════════════╡
227
+ │ Netherlands ┆ country ┆ 528 ┆ 0 ┆ {"Feature",{"Netherland│
228
+ │ Drenthe ┆ province ┆ NL13 ┆ 2 ┆ {"Feature",{"Drenthe",2│
229
+ │ … ┆ … ┆ … ┆ … ┆ … │
230
+ │ Zuid-Holland ┆ province ┆ NL33 ┆ 2 ┆ {"Feature",{"Zuid-Holla│
231
+ └───────────────┴─────────────┴───────────────┴──────────────┴────────────────────────┘
232
+
233
+ For readability, the output only a limited number of dataframe columns are displayed.
234
+ Attributes in both the demographics and geojson dataframes are available to connect the geojson to
235
+ the demographics data. This allows you quickly make data sets that contain both demographics and geojson data
236
+ for further analysis or visualisation in map applications.
237
+
238
+
239
+ Read more
240
+ ---------
241
+
242
+ * `The DataGarden Website <https://www.the-datagarden.io>`_
243
+ * `API Documentation <https://www.the-datagarden.io/api-docs>`_
244
+ * `The Datagarden Models <https://www.the-datagarden.io/data-docs>`_
245
+ * `GitHub Repository <https://github.com/MaartendeRuyter/dg-the-datagarden>`_
246
+
247
+
248
+ Access to The DataGarden API
249
+ ----------------------------
250
+ To use the DataGarden SDK, you need access to the The DataGarden API. Simply register for free at https://www.the-datagarden.io
251
+ and you will have an inital free access account to the API with access to country and continent data.
252
+
253
+ Visit https://www.the-datagarden.io to register for free.
@@ -1,137 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: the-datagarden
3
- Version: 1.2.1
4
- Summary: Public data made easy.
5
- Author-email: Maarten de Ruyter <info@the-datagarden.io>
6
- License: MIT
7
- Project-URL: Read the Docs, https://the-datagarden.readthedocs.io/
8
- Project-URL: The-DataGarden, https://www.the-datagarden.io/
9
- Project-URL: API documentation, https://api.the-datagarden.io/api-docs
10
- Project-URL: Source, https://github.com/the-datagarden/the-datagarden
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Classifier: License :: OSI Approved :: MIT License
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Development Status :: 4 - Beta
19
- Classifier: Intended Audience :: Developers
20
- Classifier: Intended Audience :: Financial and Insurance Industry
21
- Classifier: Intended Audience :: Science/Research
22
- Classifier: Intended Audience :: Healthcare Industry
23
- Classifier: Topic :: Scientific/Engineering :: GIS
24
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
26
- Classifier: Topic :: Scientific/Engineering :: Visualization
27
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
- Classifier: Topic :: Utilities
29
- Requires-Python: >=3.10
30
- Description-Content-Type: text/x-rst
31
- Requires-Dist: click>=8.1.7
32
- Requires-Dist: pandas>=2.2.3
33
- Requires-Dist: polars>=1.15.0
34
- Requires-Dist: pydantic>=2.9.2
35
- Requires-Dist: pyjwt>=2.10.0
36
- Requires-Dist: python-decouple>=3.8
37
- Requires-Dist: requests>=2.32.3
38
- Requires-Dist: the-datagarden-models>=1.6.3
39
-
40
- ==================
41
- the-datagarden SDK
42
- ==================
43
-
44
- The-datagarden package is a Python SDK built on top of The-DataGarden API. It provides easy access to continent and country regional hierarchies, as well as public data related to these regions. Additionally, you can retrieve regional GeoJSONs using the SDK. It simplifies the process of converting regional data into DataFrames and/or GeoJSON Feature collections, enabling developers to build upon this data effortlessly.
45
-
46
- A quick example
47
- ---------------
48
- If you have a user account at the-datagarden.io, you can start using the SDK right away:
49
-
50
- .. code-block:: python
51
-
52
- # Retrieve a country object from the datagarden API
53
- >>> from the-datagarden import TheDataGardenAPI
54
- >>> the_datagarden_api = TheDataGardenAPI(email='your-email@example.com', password='your-password')
55
- >>> nl = the_datagarden_api.netherlands()
56
- >>> nl_demographics = nl.demographics(from_period="2010-01-01", source="united nations")
57
- >>> nl_demographics
58
- TheDataGardenRegionalDataModel : Demographics : (count=15)
59
-
60
- this returns a `TheDataGardenRegionalDataModel` containimg the demographics data in this case 15 records.
61
- Each of those records will contain a Demographics object for the region for the specified period.
62
-
63
- To work with this data, you can convert it to a pandas or polars dataframe and select the data from the demographics
64
- data model you need.
65
-
66
- .. code-block:: python
67
-
68
- >>> df = nl_demographics.to_polars({"pop_count": "population.total"}) # or to_pandas(...)
69
- >>> df["name", "source_name", "period", "data_model_name", "total"]
70
- ┌─────────────┬────────────────┬─────────────────┬─────────────────┬─────────────┐
71
- │ name ┆ source_name ┆ period ┆ data_model_name ┆ pop_count │
72
- │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
73
- │ str ┆ str ┆ str ┆ str ┆ f64 │
74
- ╞═════════════╪════════════════╪═════════════════╪═════════════════╪═════════════╡
75
- │ Netherlands ┆ United Nations ┆ 2010-01-010:00Z ┆ Demographics ┆ 1.6729801e7 │
76
- │ Netherlands ┆ United Nations ┆ 2011-01-010:00Z ┆ Demographics ┆ 1.6812669e7 │
77
- │ Netherlands ┆ United Nations ┆ 2012-01-010:00Z ┆ Demographics ┆ 1.6889445e7 │
78
- │ Netherlands ┆ United Nations ┆ 2013-01-010:00Z ┆ Demographics ┆ 1.6940942e7 │
79
- │ Netherlands ┆ United Nations ┆ 2014-01-010:00Z ┆ Demographics ┆ 1.6993184e7 │
80
- │ … ┆ … ┆ … ┆ … ┆ … │
81
- │ Netherlands ┆ United Nations ┆ 2020-01-010:00Z ┆ Demographics ┆ 1.7601682e7 │
82
- │ Netherlands ┆ United Nations ┆ 2021-01-010:00Z ┆ Demographics ┆ 1.767178e7 │
83
- │ Netherlands ┆ United Nations ┆ 2022-01-010:00Z ┆ Demographics ┆ 1.7789347e7 │
84
- │ Netherlands ┆ United Nations ┆ 2023-01-010:00Z ┆ Demographics ┆ 1.8019495e7 │
85
- │ Netherlands ┆ United Nations ┆ 2024-01-010:00Z ┆ Demographics ┆ null │
86
- └─────────────┴────────────────┴─────────────────┴─────────────────┴─────────────┘
87
-
88
-
89
- Retrieving the GeoJSON for the Netherlands and its provinces is straightforward as well:
90
-
91
- .. code-block:: python
92
-
93
- >>> nl_geojson = nl.geojsons()
94
- >>> nl_geojson
95
- TheDataGardenRegionGeoJSONModel : GeoJSON : (count=1)
96
- >>> nl_geojson(region_level=2) # Retrieve GeoJSON for 2nd regional level (provinces)
97
- TheDataGardenRegionGeoJSONModel : GeoJSON : (count=13) # 12 provinces + 1 country
98
- >>> df = nl_geojson.to_polars()
99
- >>> df["name", "region_type", "local_region_code", "region_level", "feature"]
100
- ┌───────────────┬─────────────┬───────────────┬──────────────┬────────────────────────┐
101
- │ name ┆ region_type ┆ local_region_c┆ region_level ┆ feature │
102
- │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
103
- │ str ┆ str ┆ str ┆ i64 ┆ struct[3] │
104
- ╞═══════════════╪═════════════╪═══════════════╪══════════════╪════════════════════════╡
105
- │ Netherlands ┆ country ┆ 528 ┆ 0 ┆ {"Feature",{"Netherland│
106
- │ Drenthe ┆ province ┆ NL13 ┆ 2 ┆ {"Feature",{"Drenthe",2│
107
- │ Flevoland ┆ province ┆ NL23 ┆ 2 ┆ {"Feature",{"Flevoland"│
108
- │ Friesland ┆ province ┆ NL12 ┆ 2 ┆ {"Feature",{"Friesland"│
109
- │ Gelderland ┆ province ┆ NL22 ┆ 2 ┆ {"Feature",{"Gelderland│
110
- │ … ┆ … ┆ … ┆ … ┆ … │
111
- │ Noord-Holland ┆ province ┆ NL32 ┆ 2 ┆ {"Feature",{"Noord-Holl│
112
- │ Overijssel ┆ province ┆ NL21 ┆ 2 ┆ {"Feature",{"Overijssel│
113
- │ Utrecht ┆ province ┆ NL31 ┆ 2 ┆ {"Feature",{"Utrecht",2│
114
- │ Zeeland ┆ province ┆ NL34 ┆ 2 ┆ {"Feature",{"Zeeland",2│
115
- │ Zuid-Holland ┆ province ┆ NL33 ┆ 2 ┆ {"Feature",{"Zuid-Holla│
116
- └───────────────┴─────────────┴───────────────┴──────────────┴────────────────────────┘
117
-
118
- For readability, the output only a limited number of dataframe columns are displayed.
119
- Attributes in both the demographics and geojson dataframes are available to connect the geojson to
120
- the demographics data. This allows you quickly make data sets that contain both demographics and geojson data
121
- for further analysis or visualisation in map applications.
122
-
123
-
124
- Read more
125
- ---------
126
-
127
- * `The DataGarden Website <https://www.the-datagarden.io>`_
128
- * `API Documentation <https://www.the-datagarden.io/api-docs>`_
129
- * `The Datagarden Models <https://www.the-datagarden.io/data-docs>`_
130
- * `GitHub Repository <https://github.com/MaartendeRuyter/dg-the-datagarden>`_
131
-
132
- Access to The DataGarden API
133
- ----------------------------
134
- To use the DataGarden SDK, you need access to the The DataGarden API. Simply register for free at https://www.the-datagarden.io
135
- and you will have an inital free access account to the API with access to country and continent data.
136
-
137
- Visit https://www.the-datagarden.io for to register for free.
@@ -1,98 +0,0 @@
1
- ==================
2
- the-datagarden SDK
3
- ==================
4
-
5
- The-datagarden package is a Python SDK built on top of The-DataGarden API. It provides easy access to continent and country regional hierarchies, as well as public data related to these regions. Additionally, you can retrieve regional GeoJSONs using the SDK. It simplifies the process of converting regional data into DataFrames and/or GeoJSON Feature collections, enabling developers to build upon this data effortlessly.
6
-
7
- A quick example
8
- ---------------
9
- If you have a user account at the-datagarden.io, you can start using the SDK right away:
10
-
11
- .. code-block:: python
12
-
13
- # Retrieve a country object from the datagarden API
14
- >>> from the-datagarden import TheDataGardenAPI
15
- >>> the_datagarden_api = TheDataGardenAPI(email='your-email@example.com', password='your-password')
16
- >>> nl = the_datagarden_api.netherlands()
17
- >>> nl_demographics = nl.demographics(from_period="2010-01-01", source="united nations")
18
- >>> nl_demographics
19
- TheDataGardenRegionalDataModel : Demographics : (count=15)
20
-
21
- this returns a `TheDataGardenRegionalDataModel` containimg the demographics data in this case 15 records.
22
- Each of those records will contain a Demographics object for the region for the specified period.
23
-
24
- To work with this data, you can convert it to a pandas or polars dataframe and select the data from the demographics
25
- data model you need.
26
-
27
- .. code-block:: python
28
-
29
- >>> df = nl_demographics.to_polars({"pop_count": "population.total"}) # or to_pandas(...)
30
- >>> df["name", "source_name", "period", "data_model_name", "total"]
31
- ┌─────────────┬────────────────┬─────────────────┬─────────────────┬─────────────┐
32
- │ name ┆ source_name ┆ period ┆ data_model_name ┆ pop_count │
33
- │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
34
- │ str ┆ str ┆ str ┆ str ┆ f64 │
35
- ╞═════════════╪════════════════╪═════════════════╪═════════════════╪═════════════╡
36
- │ Netherlands ┆ United Nations ┆ 2010-01-010:00Z ┆ Demographics ┆ 1.6729801e7 │
37
- │ Netherlands ┆ United Nations ┆ 2011-01-010:00Z ┆ Demographics ┆ 1.6812669e7 │
38
- │ Netherlands ┆ United Nations ┆ 2012-01-010:00Z ┆ Demographics ┆ 1.6889445e7 │
39
- │ Netherlands ┆ United Nations ┆ 2013-01-010:00Z ┆ Demographics ┆ 1.6940942e7 │
40
- │ Netherlands ┆ United Nations ┆ 2014-01-010:00Z ┆ Demographics ┆ 1.6993184e7 │
41
- │ … ┆ … ┆ … ┆ … ┆ … │
42
- │ Netherlands ┆ United Nations ┆ 2020-01-010:00Z ┆ Demographics ┆ 1.7601682e7 │
43
- │ Netherlands ┆ United Nations ┆ 2021-01-010:00Z ┆ Demographics ┆ 1.767178e7 │
44
- │ Netherlands ┆ United Nations ┆ 2022-01-010:00Z ┆ Demographics ┆ 1.7789347e7 │
45
- │ Netherlands ┆ United Nations ┆ 2023-01-010:00Z ┆ Demographics ┆ 1.8019495e7 │
46
- │ Netherlands ┆ United Nations ┆ 2024-01-010:00Z ┆ Demographics ┆ null │
47
- └─────────────┴────────────────┴─────────────────┴─────────────────┴─────────────┘
48
-
49
-
50
- Retrieving the GeoJSON for the Netherlands and its provinces is straightforward as well:
51
-
52
- .. code-block:: python
53
-
54
- >>> nl_geojson = nl.geojsons()
55
- >>> nl_geojson
56
- TheDataGardenRegionGeoJSONModel : GeoJSON : (count=1)
57
- >>> nl_geojson(region_level=2) # Retrieve GeoJSON for 2nd regional level (provinces)
58
- TheDataGardenRegionGeoJSONModel : GeoJSON : (count=13) # 12 provinces + 1 country
59
- >>> df = nl_geojson.to_polars()
60
- >>> df["name", "region_type", "local_region_code", "region_level", "feature"]
61
- ┌───────────────┬─────────────┬───────────────┬──────────────┬────────────────────────┐
62
- │ name ┆ region_type ┆ local_region_c┆ region_level ┆ feature │
63
- │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
64
- │ str ┆ str ┆ str ┆ i64 ┆ struct[3] │
65
- ╞═══════════════╪═════════════╪═══════════════╪══════════════╪════════════════════════╡
66
- │ Netherlands ┆ country ┆ 528 ┆ 0 ┆ {"Feature",{"Netherland│
67
- │ Drenthe ┆ province ┆ NL13 ┆ 2 ┆ {"Feature",{"Drenthe",2│
68
- │ Flevoland ┆ province ┆ NL23 ┆ 2 ┆ {"Feature",{"Flevoland"│
69
- │ Friesland ┆ province ┆ NL12 ┆ 2 ┆ {"Feature",{"Friesland"│
70
- │ Gelderland ┆ province ┆ NL22 ┆ 2 ┆ {"Feature",{"Gelderland│
71
- │ … ┆ … ┆ … ┆ … ┆ … │
72
- │ Noord-Holland ┆ province ┆ NL32 ┆ 2 ┆ {"Feature",{"Noord-Holl│
73
- │ Overijssel ┆ province ┆ NL21 ┆ 2 ┆ {"Feature",{"Overijssel│
74
- │ Utrecht ┆ province ┆ NL31 ┆ 2 ┆ {"Feature",{"Utrecht",2│
75
- │ Zeeland ┆ province ┆ NL34 ┆ 2 ┆ {"Feature",{"Zeeland",2│
76
- │ Zuid-Holland ┆ province ┆ NL33 ┆ 2 ┆ {"Feature",{"Zuid-Holla│
77
- └───────────────┴─────────────┴───────────────┴──────────────┴────────────────────────┘
78
-
79
- For readability, the output only a limited number of dataframe columns are displayed.
80
- Attributes in both the demographics and geojson dataframes are available to connect the geojson to
81
- the demographics data. This allows you quickly make data sets that contain both demographics and geojson data
82
- for further analysis or visualisation in map applications.
83
-
84
-
85
- Read more
86
- ---------
87
-
88
- * `The DataGarden Website <https://www.the-datagarden.io>`_
89
- * `API Documentation <https://www.the-datagarden.io/api-docs>`_
90
- * `The Datagarden Models <https://www.the-datagarden.io/data-docs>`_
91
- * `GitHub Repository <https://github.com/MaartendeRuyter/dg-the-datagarden>`_
92
-
93
- Access to The DataGarden API
94
- ----------------------------
95
- To use the DataGarden SDK, you need access to the The DataGarden API. Simply register for free at https://www.the-datagarden.io
96
- and you will have an inital free access account to the API with access to country and continent data.
97
-
98
- Visit https://www.the-datagarden.io for to register for free.
@@ -1,137 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: the-datagarden
3
- Version: 1.2.1
4
- Summary: Public data made easy.
5
- Author-email: Maarten de Ruyter <info@the-datagarden.io>
6
- License: MIT
7
- Project-URL: Read the Docs, https://the-datagarden.readthedocs.io/
8
- Project-URL: The-DataGarden, https://www.the-datagarden.io/
9
- Project-URL: API documentation, https://api.the-datagarden.io/api-docs
10
- Project-URL: Source, https://github.com/the-datagarden/the-datagarden
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Classifier: License :: OSI Approved :: MIT License
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Development Status :: 4 - Beta
19
- Classifier: Intended Audience :: Developers
20
- Classifier: Intended Audience :: Financial and Insurance Industry
21
- Classifier: Intended Audience :: Science/Research
22
- Classifier: Intended Audience :: Healthcare Industry
23
- Classifier: Topic :: Scientific/Engineering :: GIS
24
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
26
- Classifier: Topic :: Scientific/Engineering :: Visualization
27
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
- Classifier: Topic :: Utilities
29
- Requires-Python: >=3.10
30
- Description-Content-Type: text/x-rst
31
- Requires-Dist: click>=8.1.7
32
- Requires-Dist: pandas>=2.2.3
33
- Requires-Dist: polars>=1.15.0
34
- Requires-Dist: pydantic>=2.9.2
35
- Requires-Dist: pyjwt>=2.10.0
36
- Requires-Dist: python-decouple>=3.8
37
- Requires-Dist: requests>=2.32.3
38
- Requires-Dist: the-datagarden-models>=1.6.3
39
-
40
- ==================
41
- the-datagarden SDK
42
- ==================
43
-
44
- The-datagarden package is a Python SDK built on top of The-DataGarden API. It provides easy access to continent and country regional hierarchies, as well as public data related to these regions. Additionally, you can retrieve regional GeoJSONs using the SDK. It simplifies the process of converting regional data into DataFrames and/or GeoJSON Feature collections, enabling developers to build upon this data effortlessly.
45
-
46
- A quick example
47
- ---------------
48
- If you have a user account at the-datagarden.io, you can start using the SDK right away:
49
-
50
- .. code-block:: python
51
-
52
- # Retrieve a country object from the datagarden API
53
- >>> from the-datagarden import TheDataGardenAPI
54
- >>> the_datagarden_api = TheDataGardenAPI(email='your-email@example.com', password='your-password')
55
- >>> nl = the_datagarden_api.netherlands()
56
- >>> nl_demographics = nl.demographics(from_period="2010-01-01", source="united nations")
57
- >>> nl_demographics
58
- TheDataGardenRegionalDataModel : Demographics : (count=15)
59
-
60
- this returns a `TheDataGardenRegionalDataModel` containimg the demographics data in this case 15 records.
61
- Each of those records will contain a Demographics object for the region for the specified period.
62
-
63
- To work with this data, you can convert it to a pandas or polars dataframe and select the data from the demographics
64
- data model you need.
65
-
66
- .. code-block:: python
67
-
68
- >>> df = nl_demographics.to_polars({"pop_count": "population.total"}) # or to_pandas(...)
69
- >>> df["name", "source_name", "period", "data_model_name", "total"]
70
- ┌─────────────┬────────────────┬─────────────────┬─────────────────┬─────────────┐
71
- │ name ┆ source_name ┆ period ┆ data_model_name ┆ pop_count │
72
- │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
73
- │ str ┆ str ┆ str ┆ str ┆ f64 │
74
- ╞═════════════╪════════════════╪═════════════════╪═════════════════╪═════════════╡
75
- │ Netherlands ┆ United Nations ┆ 2010-01-010:00Z ┆ Demographics ┆ 1.6729801e7 │
76
- │ Netherlands ┆ United Nations ┆ 2011-01-010:00Z ┆ Demographics ┆ 1.6812669e7 │
77
- │ Netherlands ┆ United Nations ┆ 2012-01-010:00Z ┆ Demographics ┆ 1.6889445e7 │
78
- │ Netherlands ┆ United Nations ┆ 2013-01-010:00Z ┆ Demographics ┆ 1.6940942e7 │
79
- │ Netherlands ┆ United Nations ┆ 2014-01-010:00Z ┆ Demographics ┆ 1.6993184e7 │
80
- │ … ┆ … ┆ … ┆ … ┆ … │
81
- │ Netherlands ┆ United Nations ┆ 2020-01-010:00Z ┆ Demographics ┆ 1.7601682e7 │
82
- │ Netherlands ┆ United Nations ┆ 2021-01-010:00Z ┆ Demographics ┆ 1.767178e7 │
83
- │ Netherlands ┆ United Nations ┆ 2022-01-010:00Z ┆ Demographics ┆ 1.7789347e7 │
84
- │ Netherlands ┆ United Nations ┆ 2023-01-010:00Z ┆ Demographics ┆ 1.8019495e7 │
85
- │ Netherlands ┆ United Nations ┆ 2024-01-010:00Z ┆ Demographics ┆ null │
86
- └─────────────┴────────────────┴─────────────────┴─────────────────┴─────────────┘
87
-
88
-
89
- Retrieving the GeoJSON for the Netherlands and its provinces is straightforward as well:
90
-
91
- .. code-block:: python
92
-
93
- >>> nl_geojson = nl.geojsons()
94
- >>> nl_geojson
95
- TheDataGardenRegionGeoJSONModel : GeoJSON : (count=1)
96
- >>> nl_geojson(region_level=2) # Retrieve GeoJSON for 2nd regional level (provinces)
97
- TheDataGardenRegionGeoJSONModel : GeoJSON : (count=13) # 12 provinces + 1 country
98
- >>> df = nl_geojson.to_polars()
99
- >>> df["name", "region_type", "local_region_code", "region_level", "feature"]
100
- ┌───────────────┬─────────────┬───────────────┬──────────────┬────────────────────────┐
101
- │ name ┆ region_type ┆ local_region_c┆ region_level ┆ feature │
102
- │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
103
- │ str ┆ str ┆ str ┆ i64 ┆ struct[3] │
104
- ╞═══════════════╪═════════════╪═══════════════╪══════════════╪════════════════════════╡
105
- │ Netherlands ┆ country ┆ 528 ┆ 0 ┆ {"Feature",{"Netherland│
106
- │ Drenthe ┆ province ┆ NL13 ┆ 2 ┆ {"Feature",{"Drenthe",2│
107
- │ Flevoland ┆ province ┆ NL23 ┆ 2 ┆ {"Feature",{"Flevoland"│
108
- │ Friesland ┆ province ┆ NL12 ┆ 2 ┆ {"Feature",{"Friesland"│
109
- │ Gelderland ┆ province ┆ NL22 ┆ 2 ┆ {"Feature",{"Gelderland│
110
- │ … ┆ … ┆ … ┆ … ┆ … │
111
- │ Noord-Holland ┆ province ┆ NL32 ┆ 2 ┆ {"Feature",{"Noord-Holl│
112
- │ Overijssel ┆ province ┆ NL21 ┆ 2 ┆ {"Feature",{"Overijssel│
113
- │ Utrecht ┆ province ┆ NL31 ┆ 2 ┆ {"Feature",{"Utrecht",2│
114
- │ Zeeland ┆ province ┆ NL34 ┆ 2 ┆ {"Feature",{"Zeeland",2│
115
- │ Zuid-Holland ┆ province ┆ NL33 ┆ 2 ┆ {"Feature",{"Zuid-Holla│
116
- └───────────────┴─────────────┴───────────────┴──────────────┴────────────────────────┘
117
-
118
- For readability, the output only a limited number of dataframe columns are displayed.
119
- Attributes in both the demographics and geojson dataframes are available to connect the geojson to
120
- the demographics data. This allows you quickly make data sets that contain both demographics and geojson data
121
- for further analysis or visualisation in map applications.
122
-
123
-
124
- Read more
125
- ---------
126
-
127
- * `The DataGarden Website <https://www.the-datagarden.io>`_
128
- * `API Documentation <https://www.the-datagarden.io/api-docs>`_
129
- * `The Datagarden Models <https://www.the-datagarden.io/data-docs>`_
130
- * `GitHub Repository <https://github.com/MaartendeRuyter/dg-the-datagarden>`_
131
-
132
- Access to The DataGarden API
133
- ----------------------------
134
- To use the DataGarden SDK, you need access to the The DataGarden API. Simply register for free at https://www.the-datagarden.io
135
- and you will have an inital free access account to the API with access to country and continent data.
136
-
137
- Visit https://www.the-datagarden.io for to register for free.
File without changes