pxwebpy 0.3.2__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. pxwebpy-0.5.0/.github/workflows/ci.yml +48 -0
  2. pxwebpy-0.5.0/.github/workflows/docs.yml +45 -0
  3. pxwebpy-0.5.0/.github/workflows/release.yml +29 -0
  4. pxwebpy-0.5.0/.gitignore +11 -0
  5. pxwebpy-0.5.0/.python-version +1 -0
  6. pxwebpy-0.5.0/PKG-INFO +81 -0
  7. pxwebpy-0.5.0/README.md +61 -0
  8. pxwebpy-0.5.0/docs/.gitignore +6 -0
  9. pxwebpy-0.5.0/docs/_brand.yml +19 -0
  10. pxwebpy-0.5.0/docs/_extensions/machow/interlinks/.gitignore +3 -0
  11. pxwebpy-0.5.0/docs/_extensions/machow/interlinks/_extension.yml +7 -0
  12. pxwebpy-0.5.0/docs/_extensions/machow/interlinks/interlinks.lua +411 -0
  13. pxwebpy-0.5.0/docs/_quarto.yml +62 -0
  14. pxwebpy-0.5.0/docs/examples.qmd +219 -0
  15. pxwebpy-0.5.0/docs/index.qmd +42 -0
  16. pxwebpy-0.5.0/docs/style.css +25 -0
  17. pxwebpy-0.5.0/docs/version_config.py +8 -0
  18. pxwebpy-0.5.0/pyproject.toml +60 -0
  19. pxwebpy-0.5.0/src/pxweb/__init__.py +3 -0
  20. pxwebpy-0.5.0/src/pxweb/_internal/client.py +117 -0
  21. pxwebpy-0.5.0/src/pxweb/_internal/functions.py +160 -0
  22. pxwebpy-0.5.0/src/pxweb/_version.py +1 -0
  23. pxwebpy-0.5.0/src/pxweb/api.py +596 -0
  24. pxwebpy-0.5.0/src/pxweb/py.typed +0 -0
  25. pxwebpy-0.5.0/tests/__snapshots__/test_functions.ambr +247 -0
  26. pxwebpy-0.5.0/tests/code_list_agg_/303/205lder10/303/245rJ.json +194 -0
  27. pxwebpy-0.5.0/tests/table_variables_TAB5444.json +1 -0
  28. pxwebpy-0.5.0/tests/test_api.py +74 -0
  29. pxwebpy-0.5.0/tests/test_client.py +109 -0
  30. pxwebpy-0.5.0/tests/test_functions.py +77 -0
  31. pxwebpy-0.5.0/uv.lock +2076 -0
  32. pxwebpy-0.3.2/.github/workflows/ci.yml +0 -62
  33. pxwebpy-0.3.2/.github/workflows/release.yml +0 -31
  34. pxwebpy-0.3.2/.gitignore +0 -6
  35. pxwebpy-0.3.2/PKG-INFO +0 -127
  36. pxwebpy-0.3.2/README.md +0 -106
  37. pxwebpy-0.3.2/examples/example.py +0 -83
  38. pxwebpy-0.3.2/examples/example_query.json +0 -45
  39. pxwebpy-0.3.2/pyproject.toml +0 -45
  40. pxwebpy-0.3.2/src/pxwebpy/table.py +0 -336
  41. pxwebpy-0.3.2/tests/invalid_query.json +0 -12
  42. pxwebpy-0.3.2/tests/mock/response_fi.json +0 -233
  43. pxwebpy-0.3.2/tests/mock/response_gl.json +0 -271
  44. pxwebpy-0.3.2/tests/mock/response_no.json +0 -506
  45. pxwebpy-0.3.2/tests/mock/response_table_variables.json +0 -835
  46. pxwebpy-0.3.2/tests/mock/result_fi.json +0 -632
  47. pxwebpy-0.3.2/tests/mock/result_gl.json +0 -866
  48. pxwebpy-0.3.2/tests/mock/result_no.json +0 -2018
  49. pxwebpy-0.3.2/tests/queries.json +0 -182
  50. pxwebpy-0.3.2/tests/test_table.py +0 -182
  51. pxwebpy-0.3.2/tests/valid_query.json +0 -45
  52. pxwebpy-0.3.2/uv.lock +0 -945
  53. {pxwebpy-0.3.2 → pxwebpy-0.5.0}/LICENSE +0 -0
  54. {pxwebpy-0.3.2/src/pxwebpy → pxwebpy-0.5.0/src/pxweb/_internal}/__init__.py +0 -0
@@ -0,0 +1,48 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ build:
12
+ name: ${{ matrix.os }} python-${{ matrix.python-version }}
13
+
14
+ strategy:
15
+ matrix:
16
+ os:
17
+ - ubuntu-latest
18
+ - windows-latest
19
+ - macos-latest
20
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
21
+ fail-fast: false
22
+
23
+ runs-on: ${{ matrix.os }}
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ with:
27
+ fetch-depth: 0
28
+
29
+ - name: Set up Python ${{ matrix.python-version }}
30
+ uses: actions/setup-python@v5
31
+ with:
32
+ python-version: ${{ matrix.python-version }}
33
+
34
+ - name: Install uv
35
+ uses: astral-sh/setup-uv@v6
36
+ with:
37
+ version: "0.8.3"
38
+ enable-cache: true
39
+ cache-dependency-glob: "uv.lock"
40
+ python-version: ${{ matrix.python-version }}
41
+
42
+ - name: Install the project
43
+ run: uv sync --dev --frozen
44
+
45
+ - name: Run tests & build
46
+ run: |
47
+ uv run pytest
48
+ uv build
@@ -0,0 +1,45 @@
1
+ name: docs
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build-docs:
10
+ runs-on: ubuntu-latest
11
+ environment: release
12
+ permissions:
13
+ contents: write
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Install Python and dependencies
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version-file: ".python-version"
24
+
25
+ - name: Install uv
26
+ uses: astral-sh/setup-uv@v6
27
+ with:
28
+ version: "0.8.3"
29
+
30
+ - name: Set up Quarto
31
+ uses: quarto-dev/quarto-actions/setup@v2
32
+
33
+ - name: Build docs
34
+ run: |
35
+ uv sync --dev --frozen
36
+ cd docs && uv run quartodoc build
37
+
38
+ - name: Render and publish
39
+ uses: quarto-dev/quarto-actions/publish@v2
40
+ with:
41
+ target: gh-pages
42
+ path: docs
43
+ env:
44
+ QUARTO_PYTHON: ${{ github.workspace }}/.venv/bin/python
45
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,29 @@
1
+ name: release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build-release:
10
+ runs-on: ubuntu-latest
11
+ environment: release
12
+ permissions:
13
+ id-token: write
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Install uv
21
+ uses: astral-sh/setup-uv@v6
22
+ with:
23
+ version: "0.8.3"
24
+
25
+ - name: Build for distribution
26
+ run: uv build
27
+
28
+ - name: Publish to PyPI
29
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ .mypy_cache
3
+ .venv
4
+ dist/
5
+ .pytest_cache
6
+ .ruff_cache
7
+ .coverage
8
+ htmlcov
9
+
10
+ # Generated version files
11
+ _version.py
@@ -0,0 +1 @@
1
+ 3.13
pxwebpy-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: pxwebpy
3
+ Version: 0.5.0
4
+ Summary: Client library for the PxWeb API to easily load data into a DataFrame.
5
+ Project-URL: Repository, https://github.com/stefur/pxwebpy
6
+ Author-email: Stefan Furne <stefan@furne.net>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: dataframes,pandas,polars,pxweb,statistics
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3 :: Only
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
+ Requires-Python: >=3.10
17
+ Requires-Dist: requests-cache>=1.2.1
18
+ Requires-Dist: requests>=2.32.3
19
+ Description-Content-Type: text/markdown
20
+
21
+ # pxwebpy
22
+ [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/stefur/pxwebpy/ci.yml?style=flat-square&label=ci)](https://github.com/stefur/pxwebpy/actions/workflows/ci.yml)
23
+ ![PyPI - Version](https://img.shields.io/pypi/v/pxwebpy?style=flat-square)
24
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pxwebpy?style=flat-square)
25
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json&style=flat-square)](https://github.com/astral-sh/uv)
26
+ [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square)](https://github.com/astral-sh/ruff)
27
+ Client library for the PxWeb API to easily load data into a DataFrame.
28
+
29
+ [Get started](https://stefur.github.io/pxwebpy) | [Examples](https://stefur.github.io/pxwebpy/examples) | [Reference](https://stefur.github.io/pxwebpy/reference)
30
+
31
+ ## Features
32
+ - Automatic query batching to handle large queries to respect rate limits
33
+ - Multithreading for faster data fetching on large queries
34
+ - In-memory caching for quicker iterative use and exploration
35
+ - Wildcard support in queries
36
+ - BYODF (Bring Your Own DataFrame): native return formats for use with `pandas` or `polars`
37
+ - Search for tables, browse and list tables, get metadata, and more
38
+
39
+ It has been tested with [Statistics Sweden](https://scb.se) and [Statistics Norway](https://www.ssb.no).
40
+
41
+ > [!NOTE]
42
+ > Note that pxwebpy only supports version 2.0 of the PxWeb API.
43
+
44
+ ## Quick start
45
+ ```python
46
+ >>> from pxweb import PxApi
47
+ >>> import polars as pl
48
+
49
+ # Prepare to get data from the Statistics Norway API by using the builtin URL
50
+ >>> api = PxApi("ssb")
51
+
52
+ # Set the language to english
53
+ >>> api.language = "en"
54
+
55
+ # Check the population per year in Norway during the 1990's
56
+ >>> data = api.get_table_data("06913", value_codes={"Region": "0", "ContentsCode": "Folkemengde", "Tid": "199*"})
57
+
58
+ # Turn it into a polars dataframe
59
+ >>> df = pl.DataFrame(data)
60
+
61
+ # A quick look at the result
62
+ >>> print(df)
63
+
64
+ shape: (10, 4)
65
+ ┌─────────────────────┬──────────────────────┬──────┬─────────┐
66
+ │ region ┆ contents ┆ year ┆ value │
67
+ │ --- ┆ --- ┆ --- ┆ --- │
68
+ │ str ┆ str ┆ str ┆ i64 │
69
+ ╞═════════════════════╪══════════════════════╪══════╪═════════╡
70
+ │ 0 The whole country ┆ Population 1 January ┆ 1990 ┆ 4233116 │
71
+ │ 0 The whole country ┆ Population 1 January ┆ 1991 ┆ 4249830 │
72
+ │ 0 The whole country ┆ Population 1 January ┆ 1992 ┆ 4273634 │
73
+ │ 0 The whole country ┆ Population 1 January ┆ 1993 ┆ 4299167 │
74
+ │ 0 The whole country ┆ Population 1 January ┆ 1994 ┆ 4324815 │
75
+ │ 0 The whole country ┆ Population 1 January ┆ 1995 ┆ 4348410 │
76
+ │ 0 The whole country ┆ Population 1 January ┆ 1996 ┆ 4369957 │
77
+ │ 0 The whole country ┆ Population 1 January ┆ 1997 ┆ 4392714 │
78
+ │ 0 The whole country ┆ Population 1 January ┆ 1998 ┆ 4417599 │
79
+ │ 0 The whole country ┆ Population 1 January ┆ 1999 ┆ 4445329 │
80
+ └─────────────────────┴──────────────────────┴──────┴─────────┘
81
+ ```
@@ -0,0 +1,61 @@
1
+ # pxwebpy
2
+ [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/stefur/pxwebpy/ci.yml?style=flat-square&label=ci)](https://github.com/stefur/pxwebpy/actions/workflows/ci.yml)
3
+ ![PyPI - Version](https://img.shields.io/pypi/v/pxwebpy?style=flat-square)
4
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pxwebpy?style=flat-square)
5
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json&style=flat-square)](https://github.com/astral-sh/uv)
6
+ [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square)](https://github.com/astral-sh/ruff)
7
+ Client library for the PxWeb API to easily load data into a DataFrame.
8
+
9
+ [Get started](https://stefur.github.io/pxwebpy) | [Examples](https://stefur.github.io/pxwebpy/examples) | [Reference](https://stefur.github.io/pxwebpy/reference)
10
+
11
+ ## Features
12
+ - Automatic query batching to handle large queries to respect rate limits
13
+ - Multithreading for faster data fetching on large queries
14
+ - In-memory caching for quicker iterative use and exploration
15
+ - Wildcard support in queries
16
+ - BYODF (Bring Your Own DataFrame): native return formats for use with `pandas` or `polars`
17
+ - Search for tables, browse and list tables, get metadata, and more
18
+
19
+ It has been tested with [Statistics Sweden](https://scb.se) and [Statistics Norway](https://www.ssb.no).
20
+
21
+ > [!NOTE]
22
+ > Note that pxwebpy only supports version 2.0 of the PxWeb API.
23
+
24
+ ## Quick start
25
+ ```python
26
+ >>> from pxweb import PxApi
27
+ >>> import polars as pl
28
+
29
+ # Prepare to get data from the Statistics Norway API by using the builtin URL
30
+ >>> api = PxApi("ssb")
31
+
32
+ # Set the language to english
33
+ >>> api.language = "en"
34
+
35
+ # Check the population per year in Norway during the 1990's
36
+ >>> data = api.get_table_data("06913", value_codes={"Region": "0", "ContentsCode": "Folkemengde", "Tid": "199*"})
37
+
38
+ # Turn it into a polars dataframe
39
+ >>> df = pl.DataFrame(data)
40
+
41
+ # A quick look at the result
42
+ >>> print(df)
43
+
44
+ shape: (10, 4)
45
+ ┌─────────────────────┬──────────────────────┬──────┬─────────┐
46
+ │ region ┆ contents ┆ year ┆ value │
47
+ │ --- ┆ --- ┆ --- ┆ --- │
48
+ │ str ┆ str ┆ str ┆ i64 │
49
+ ╞═════════════════════╪══════════════════════╪══════╪═════════╡
50
+ │ 0 The whole country ┆ Population 1 January ┆ 1990 ┆ 4233116 │
51
+ │ 0 The whole country ┆ Population 1 January ┆ 1991 ┆ 4249830 │
52
+ │ 0 The whole country ┆ Population 1 January ┆ 1992 ┆ 4273634 │
53
+ │ 0 The whole country ┆ Population 1 January ┆ 1993 ┆ 4299167 │
54
+ │ 0 The whole country ┆ Population 1 January ┆ 1994 ┆ 4324815 │
55
+ │ 0 The whole country ┆ Population 1 January ┆ 1995 ┆ 4348410 │
56
+ │ 0 The whole country ┆ Population 1 January ┆ 1996 ┆ 4369957 │
57
+ │ 0 The whole country ┆ Population 1 January ┆ 1997 ┆ 4392714 │
58
+ │ 0 The whole country ┆ Population 1 January ┆ 1998 ┆ 4417599 │
59
+ │ 0 The whole country ┆ Population 1 January ┆ 1999 ┆ 4445329 │
60
+ └─────────────────────┴──────────────────────┴──────┴─────────┘
61
+ ```
@@ -0,0 +1,6 @@
1
+ /.quarto/
2
+ reference
3
+ _site
4
+ objects.json
5
+ _environment
6
+ **/*.quarto_ipynb
@@ -0,0 +1,19 @@
1
+ color:
2
+ palette:
3
+ black: "#1A1A1A"
4
+ white: "#FCFCFC"
5
+ green: "#2c5545"
6
+ foreground: black
7
+ background: white
8
+ primary: green
9
+
10
+ typography:
11
+ fonts:
12
+ - family: Fira Code
13
+ source: google
14
+
15
+ base: Arial
16
+ headings:
17
+ family: Arial
18
+ weight: 400
19
+ monospace: Fira Code
@@ -0,0 +1,3 @@
1
+ *.html
2
+ *.pdf
3
+ *_files/
@@ -0,0 +1,7 @@
1
+ title: Interlinks
2
+ author: Michael Chow
3
+ version: 1.1.0
4
+ quarto-required: ">=1.2.0"
5
+ contributes:
6
+ filters:
7
+ - interlinks.lua