A modern Python client for CBS Statline open data that returns Polars DataFrames with human-readable column names.
- Github repository: https://github.com/thomaspinder/cbspy/
- Documentation: https://thomaspinder.github.io/cbspy/
pip install cbspyimport cbspy
client = cbspy.Client()
# Discover available tables
tables = client.list_tables(language="en")
print(tables.head())
# shape: (5, 7)
# id, title, description, period, frequency, record_count, modified
# Inspect a table's structure
meta = client.get_metadata("37296eng")
for col in meta.properties:
print(f"{col.id}: {col.display_name} ({col.unit})")
# Fetch data with human-readable column names
df = client.get_data("37296eng")
print(df.head())
# Columns like "Total population", "Males", "Females" instead of
# "TotalPopulation_1", "Males_2", "Females_3"
# Filter by time period
df = client.get_data("37296eng", periods=["2022JJ00", "2023JJ00"])make install # Create venv and install pre-commit hooks
make test # Run tests with coverage
make check # Run linting and type checkingRepository initiated with fpgmaas/cookiecutter-uv.