pxwebpy is a Python client for the PxWeb API. The goal is to make it easier to get data from the API and into a dataframe. It is BYODF* so that you can use what DataFrame library you prefer, be it polars, pandas or a pyarrow table.
* = Bring your own dataframe
Installation
The package is on PyPI and the easiest way to install it into your environment is:
pip install pxwebpy
Or by using uv:
uv add pxwebpy
Usage
from pxweb import PxApiimport polars as plapi = PxApi("scb")# Swedish population per yeardata = api.get_table_data( table_id="TAB5890", value_codes={"Tid": ["2022", "2023", "2024"], "ContentsCode": "0000053A"},)pl.DataFrame(data)