PxStatsPy
A comprehensive Python wrapper for the Statistics Sweden PxWebAPI 2.0, providing easy access to Swedish statistical data.
Note: This is an independent project and is not associated with Statistics Sweden (SCB).
Features
- Complete Python interface for Statistics Sweden's PxWebAPI 2.0
- Comprehensive search functionality for statistical tables
- Flexible data filtering and selection options
- Support for multiple data formats:
- Pandas DataFrames with customizable options
- JSON (json-stat2 format)
- CSV with various delimiter options
- Built-in API rate limit controls
- Built-in error handling and intelligent response parsing
- Multilanguage support (Swedish/English)
Requirements
- Python 3.7 or higher
- Dependencies:
- pandas >= 1.0.0
- requests >= 2.25.0
Installation
Install the latest version:
pip install pxstatspy
For development installation:
git clone https://github.com/xemarap/pxstatspy.git
cd pxstatspy
pip install -e .
Quick Start
Visit the PxStatsPy - Get started tutorial notebook for extensive usage guide.
from pxstatspy import PxAPI, PxAPIConfig, OutputFormat, OutputFormatParam
# Initialize client
config = PxAPIConfig(
base_url="https://statistikdatabasen.scb.se/api/v2",
language="en" # or "sv" for Swedish
)
client = PxAPI(config)
# Search for population statistics tables updated last 30 days
client.find_tables(
query="Population",
past_days=30,
display=True
)
# Get data as DataFrame
df = client.get_data_as_dataframe(
table_id="TAB1267",
value_codes={
"Tid": ["2024"],
"Region": ["00", "01"],
"ContentsCode": ["BE0101A9"]
}
)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Submit suggestions and report bugs (for faster troubleshooting please enable debug mode and submit the errormessage)
- Open a Pull Request
- Star the GitHub page
Resources
License
This project is licensed under the MIT License - see the LICENSE file for details.
This project uses the following open source resources:
The full license texts are available in the LICENSES directory.
Acknowledgments
- Statistics Sweden for providing the PxWebAPI 2.0
- Contributors to the project
Metadata
Release files for pxstatspy 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pxstatspy-1.0.1.tar.gz | 20.1 kB | Without provenance | Details for pxstatspy-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pxstatspy-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for pxstatspy-1.0.1-py3-none-any.whl |
Total release size: 38.1 kB
Release files / pxstatspy-1.0.1.tar.gz
| Download URL | pxstatspy-1.0.1.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25877d0612734ae9308f565dca7fdef6c8027b8420c328130151552947a097b3
|
|
BLAKE2b-256 checksum How to use checksums |
8e10afe1e990fe1dd703079636980adf084d69480bbf2efe05eccf945bf6b8f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Release files / pxstatspy-1.0.1-py3-none-any.whl
| Download URL | pxstatspy-1.0.1-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5bd1291099ead679afbc36bf5c03ce4f6b8d2a673183fd2261c6ba04e3df6e59
|
|
BLAKE2b-256 checksum How to use checksums |
bae9ab6a55d1c70a3eb5ff6f3bcd49bfe8480fd60ee16b1e48d8950830aeeb39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Security for pxstatspy 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.