Skip to main content

pxwebpy

GitHub Actions Workflow Status PyPI - Version PyPI - Python Version uv ruff
Client library for the PxWeb API to easily load data into a DataFrame.

Get started | Examples | Reference

Features

  • Automatic query batching to handle large queries to respect rate limits
  • Multithreading for faster data fetching on large queries
  • In-memory caching for quicker iterative use and exploration
  • Wildcard support in queries
  • BYODF (Bring Your Own DataFrame): native return formats for use with pandas or polars
  • Search for tables, browse and list tables, get metadata, and more

It has been tested with Statistics Sweden and Statistics Norway.

[!NOTE]
pxwebpy only supports version 2.0 of the PxWeb API.

Quick start

from pxweb import PxApi
import polars as pl

# Prepare to get data from the Statistics Norway API by using the builtin URL
api = PxApi("ssb")

# Set the language to english
api.language = "en"

# Check the population per year in Norway during the 1990's
data = api.get_table_data(
    "06913",
    value_codes={"Region": "0", "ContentsCode": "Folkemengde", "Tid": "199*"},
)

# Turn it into a polars dataframe
df = pl.DataFrame(data)

# A quick look at the result
print(df)
shape: (10, 4)
┌─────────────────────┬──────────────────────┬──────┬─────────┐
│ region              ┆ contents             ┆ year ┆ value   │
│ ---                 ┆ ---                  ┆ ---  ┆ ---     │
│ str                 ┆ str                  ┆ str  ┆ i64     │
╞═════════════════════╪══════════════════════╪══════╪═════════╡
│ 0 The whole country ┆ Population 1 January ┆ 1990 ┆ 4233116 │
│ 0 The whole country ┆ Population 1 January ┆ 1991 ┆ 4249830 │
│ 0 The whole country ┆ Population 1 January ┆ 1992 ┆ 4273634 │
│ 0 The whole country ┆ Population 1 January ┆ 1993 ┆ 4299167 │
│ 0 The whole country ┆ Population 1 January ┆ 1994 ┆ 4324815 │
│ 0 The whole country ┆ Population 1 January ┆ 1995 ┆ 4348410 │
│ 0 The whole country ┆ Population 1 January ┆ 1996 ┆ 4369957 │
│ 0 The whole country ┆ Population 1 January ┆ 1997 ┆ 4392714 │
│ 0 The whole country ┆ Population 1 January ┆ 1998 ┆ 4417599 │
│ 0 The whole country ┆ Population 1 January ┆ 1999 ┆ 4445329 │
└─────────────────────┴──────────────────────┴──────┴─────────┘

Metadata

Release files for pxwebpy 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pxwebpy 0.6.0
File Size Uploaded
pxwebpy-0.6.0.tar.gz 168.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pxwebpy 0.6.0
File Interpreter ABI Platform
pxwebpy-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 184.9 kB

Release files / pxwebpy-0.6.0.tar.gz

Download URL pxwebpy-0.6.0.tar.gz
Size 168.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1440df7ab907ee452fd28c53b4fbbc5cc1b7d6ecc4a9b8bb29221e45b507def4
BLAKE2b-256 checksum
How to use checksums
d8855d94f48c6425a29344f38b89f3838e404a2dcee84d61a1ed8f7e21421014
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pxwebpy-0.6.0-py3-none-any.whl

Download URL pxwebpy-0.6.0-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a30c0db859cc250355a52f7ecd8fb93115f6c2dfb602ce7b483cea7379f207ed
BLAKE2b-256 checksum
How to use checksums
b4b61fb341cfed4d1732f3930dbc7ed7a39e29acf90ee16a12b5fde0f6ea9437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page