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.
- pxwebpy-0.5.0/.github/workflows/ci.yml +48 -0
- pxwebpy-0.5.0/.github/workflows/docs.yml +45 -0
- pxwebpy-0.5.0/.github/workflows/release.yml +29 -0
- pxwebpy-0.5.0/.gitignore +11 -0
- pxwebpy-0.5.0/.python-version +1 -0
- pxwebpy-0.5.0/PKG-INFO +81 -0
- pxwebpy-0.5.0/README.md +61 -0
- pxwebpy-0.5.0/docs/.gitignore +6 -0
- pxwebpy-0.5.0/docs/_brand.yml +19 -0
- pxwebpy-0.5.0/docs/_extensions/machow/interlinks/.gitignore +3 -0
- pxwebpy-0.5.0/docs/_extensions/machow/interlinks/_extension.yml +7 -0
- pxwebpy-0.5.0/docs/_extensions/machow/interlinks/interlinks.lua +411 -0
- pxwebpy-0.5.0/docs/_quarto.yml +62 -0
- pxwebpy-0.5.0/docs/examples.qmd +219 -0
- pxwebpy-0.5.0/docs/index.qmd +42 -0
- pxwebpy-0.5.0/docs/style.css +25 -0
- pxwebpy-0.5.0/docs/version_config.py +8 -0
- pxwebpy-0.5.0/pyproject.toml +60 -0
- pxwebpy-0.5.0/src/pxweb/__init__.py +3 -0
- pxwebpy-0.5.0/src/pxweb/_internal/client.py +117 -0
- pxwebpy-0.5.0/src/pxweb/_internal/functions.py +160 -0
- pxwebpy-0.5.0/src/pxweb/_version.py +1 -0
- pxwebpy-0.5.0/src/pxweb/api.py +596 -0
- pxwebpy-0.5.0/src/pxweb/py.typed +0 -0
- pxwebpy-0.5.0/tests/__snapshots__/test_functions.ambr +247 -0
- pxwebpy-0.5.0/tests/code_list_agg_/303/205lder10/303/245rJ.json +194 -0
- pxwebpy-0.5.0/tests/table_variables_TAB5444.json +1 -0
- pxwebpy-0.5.0/tests/test_api.py +74 -0
- pxwebpy-0.5.0/tests/test_client.py +109 -0
- pxwebpy-0.5.0/tests/test_functions.py +77 -0
- pxwebpy-0.5.0/uv.lock +2076 -0
- pxwebpy-0.3.2/.github/workflows/ci.yml +0 -62
- pxwebpy-0.3.2/.github/workflows/release.yml +0 -31
- pxwebpy-0.3.2/.gitignore +0 -6
- pxwebpy-0.3.2/PKG-INFO +0 -127
- pxwebpy-0.3.2/README.md +0 -106
- pxwebpy-0.3.2/examples/example.py +0 -83
- pxwebpy-0.3.2/examples/example_query.json +0 -45
- pxwebpy-0.3.2/pyproject.toml +0 -45
- pxwebpy-0.3.2/src/pxwebpy/table.py +0 -336
- pxwebpy-0.3.2/tests/invalid_query.json +0 -12
- pxwebpy-0.3.2/tests/mock/response_fi.json +0 -233
- pxwebpy-0.3.2/tests/mock/response_gl.json +0 -271
- pxwebpy-0.3.2/tests/mock/response_no.json +0 -506
- pxwebpy-0.3.2/tests/mock/response_table_variables.json +0 -835
- pxwebpy-0.3.2/tests/mock/result_fi.json +0 -632
- pxwebpy-0.3.2/tests/mock/result_gl.json +0 -866
- pxwebpy-0.3.2/tests/mock/result_no.json +0 -2018
- pxwebpy-0.3.2/tests/queries.json +0 -182
- pxwebpy-0.3.2/tests/test_table.py +0 -182
- pxwebpy-0.3.2/tests/valid_query.json +0 -45
- pxwebpy-0.3.2/uv.lock +0 -945
- {pxwebpy-0.3.2 → pxwebpy-0.5.0}/LICENSE +0 -0
- {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
|
pxwebpy-0.5.0/.gitignore
ADDED
|
@@ -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
|
+
[](https://github.com/stefur/pxwebpy/actions/workflows/ci.yml)
|
|
23
|
+

|
|
24
|
+

|
|
25
|
+
[](https://github.com/astral-sh/uv)
|
|
26
|
+
[](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
|
+
```
|
pxwebpy-0.5.0/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# pxwebpy
|
|
2
|
+
[](https://github.com/stefur/pxwebpy/actions/workflows/ci.yml)
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://github.com/astral-sh/uv)
|
|
6
|
+
[](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,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
|