sas_to_polars
A light Python package for converting and processing SAS datasets (.sas7bdat files) into a Polars DataFrame. Designed for high-performance data transformation by leveraging parallel computing.
Table of Contents
Overview
This package provides a fast and convenient way to read SAS datasets into Polars DataFrames. Converting SAS datasets in Python often requires specific libraries. For large datasets, the conversion process can be a bottleneck. This package addresses this by leveraging concurrent programming to speed up the conversion.
sas_to_polars allows users to quickly transform their SAS data into the efficient Polars DataFrame structure for further analysis and manipulation in Python.
Installation
This package requires Python 3.8 or higher.
The following Python libraries are necessary and will be installed as dependencies:
pyreadstat: For reading SAS datasets.polars: For high-performance data manipulation.pyarrow: For efficient data conversion (required by Polars).
You can install sas_to_polars using pip:
pip install sas-to-polars # Replace with your actual package name on PyPI
After running this command, pip will resolve and install the required dependencies (pyreadstat and polars) along with your sas_to_polars package.
To verify the installation, you can run:
python -c "import sas_to_polars
If no output is returned, the installation was successful.
Usage
The primary function in this package is sas_to_polars. Here's how to use it.
from sas_to_polars import sas_to_polars
df = sas_to_polars(filepath="path/to/dataset/data.sas7bdat")
print(df.head())
The sas_to_polars function accepts the following optional parameters:
- chunksize: int = 10_000: The number of rows to read in each chunk during parallel processing.
- processes: int = mp.cpu_count() // 4: The number of parallel processes to use for conversion. Defaults to a quarter of the available CPU cores.
- use_lazy: bool = True: Whether to use Polars lazy loading for potentially more efficient out-of-memory operations.
- unordered: bool = False: Whether to maintain the original order of columns from the SAS dataset.
For more detailed information about the sas_to_polars function and its parameters, you can use Python's built-in help function:
help(sas_to_polars)
Example Dataset Output
Shape: (3, 3)
┌─────┬─────────┬──────┐
│ id ┆ name ┆ age │
│ --- ┆ --- ┆ --- │
│ f64 ┆ str ┆ f64 │
╞═════╪═════════╪══════╡
│ 1.0 ┆ Alice ┆ 30.0 │
│ 2.0 ┆ Bob ┆ 35.0 │
│ 3.0 ┆ Charlie ┆ 40.0 │
└─────┴─────────┴──────┘
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for sas-to-polars 1.0.0
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 | |
|---|---|---|---|---|
| sas_to_polars-1.0.0.tar.gz | 8.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sas_to_polars-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / sas_to_polars-1.0.0.tar.gz
| Download URL | sas_to_polars-1.0.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7cfb91b09cf9cbcbdec68f80b5f7661b47eaacff6f19440cb0d1d68b0756ab55
|
|
BLAKE2b-256 checksum How to use checksums |
249421459f8f54c50a49b9e40cfed0ae11e9afaed076f5c1b57831faaf8cd61a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / sas_to_polars-1.0.0-py3-none-any.whl
| Download URL | sas_to_polars-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1bd4dd3565cf4b87d0719350166d210b475514ca34622afcdd13689b9a654add
|
|
BLAKE2b-256 checksum How to use checksums |
2db6d18b9090bec56c51196382beb3decca213e497da29264e34771b7af875ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for sas-to-polars 1.0.0
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.