Skip to main content

dataseries: Switzerland's Data Series in One Place

PyPI CI

Download and import open Swiss economic time series from dataseries.org, a comprehensive and up-to-date collection of public data from Switzerland. The package talks to the public dataseries.org API and imports series as pandas DataFrames.

An R package with the same interface is available on CRAN.

Installation

pip install dataseries

Requires Python ≥ 3.9 and pandas.

Data model

Data on dataseries.org is organized into datasets. A dataset is a family of related series and, in most cases, a multi-dimensional cube — a single time series is one cell of that cube, addressed by the dataset plus one code per dimension. For example the GDP dataset (ch_seco_gdp) splits along three dimensions: type (nominal/real/…), structure (GDP, value added, …) and seas_adj (seasonally adjusted or not).

  • ds_catalog() lists every dataset.
  • ds_search(pattern) is a flat, searchable list of the individual series.
  • ds_meta(id) describes a dataset's dimensions and the codes within them.
  • ds(id, ...) downloads series.

Usage

import dataseries

# Browse what's available
dataseries.ds_catalog()

# Find a specific series across all datasets
dataseries.ds_search("unemployment")

# A dataset's dimensions and codes
dataseries.ds_meta("ch_seco_gdp")

# Whole dataset (long DataFrame)
dataseries.ds("ch_fso_cpi")

# One series: pass dimension codes as keyword arguments
dataseries.ds("ch_fso_cpi", item="100_100")

# Several series, restricted to a date range
dataseries.ds("ch_fso_cpi", item=["100_100", "100_1"], start="2020-01-01")

# One cell of a multi-dimensional cube, as a wide DataFrame indexed by date
dataseries.ds("ch_seco_gdp", type="real", structure="gdp", seas_adj="csa",
              wide=True)

The long format (the default) has the dimension column(s), then date (datetime) and value (float) — ready for groupby, seaborn or plotly. wide=True pivots to one column per series with a DatetimeIndex, the shape you want for .plot() or statsmodels. All series are regular (annual, quarterly or monthly); convert with e.g. .to_period("Q") if you prefer a PeriodIndex.

Dimension arguments are optional: omit them and you get the whole dataset. Filtering happens on the server, so selecting one series does not download the whole cube. Downloads are cached in memory for the session; dataseries.cache_clear() forces a fresh download.

Labels in German, French or Italian

The catalog and search index are translated. Pass lang to get titles and labels in any Swiss national language (falls back to English where a translation is missing):

dataseries.ds_catalog(lang="de")
dataseries.ds_search("arbeitslosigkeit", lang="de")

From search hit to data

ds_search() returns exactly the columns you feed back to ds():

hits = dataseries.ds_search("consumer price")
row = hits.iloc[0]
df = dataseries.ds(row["dataset"], {row["dim"]: row["code"]})

Beyond Python

Every series is also available as a plain CSV from any tool that can read a URL:

https://api.dataseries.org/series.csv?dataset=ch_fso_cpi&dims=item=100_100

Self-hosting or testing against a mirror? Point the package elsewhere with the DATASERIES_API environment variable.

License

MIT. The data itself is published by the Swiss data providers under their respective terms; see the license column in ds_catalog() and the source links in ds_meta().

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dataseries-1.0.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dataseries-1.0.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file dataseries-1.0.0.tar.gz.

File metadata

  • Download URL: dataseries-1.0.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dataseries-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9293917bb7257afe6884cf6c07bd68a42b5d6cec80f5537bef230800d5d764cf
MD5 6f4a71631894917933e29016af3a702c
BLAKE2b-256 efbcd7698e5155ce328e8f0c356aba8aa9dc922ff6dc9a71763c666770da98de

See more details on using hashes here.

Provenance

The following attestation bundles were made for dataseries-1.0.0.tar.gz:

Publisher: release.yaml on cynkra/dataseries-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dataseries-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dataseries-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dataseries-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4dc9499ea05931d32981289bc75485da6722380412fc785dafd5d9f6874862f6
MD5 1452aa57e9a22c41371c911844a45c54
BLAKE2b-256 9b21a024d1996dc08cba7e8a4a0770af67b5588a704f012b665c1291fd5f069e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dataseries-1.0.0-py3-none-any.whl:

Publisher: release.yaml on cynkra/dataseries-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page