qs2py is a Python library for working with qdata, qs2, and standalone RDS files from the R ecosystem. Import it as qs2io.
qdata translation is implemented here in Python. qs2 and RDS translation currently use the rdata project for R object decoding/encoding, via a vendored fork for compatibility. If you only need RDS, you should look at rdata first.
- ✅ You move data back and forth between R and Python fairly often.
- ✅ You mostly use R and have some
qs2orqdatadata you want to open in Python. ⚠️ You mainly have tabular data. This library can handle that, but if your workflow is table-first rather than R-interop-first, a dedicated format such as Parquet or DuckDB may be a better fit.- ❌ You primarily use Python and do not need compatibility with the R-side
qs2/qdataformats. In that case, the translation layer is mostly overhead.
qd_read/qd_save: read and writeqdataformat.qs_read/qs_save: read and writeqs2format, translated to Python viardatalibrary.rds_read/rds_save: read and writeRDSformat (via vendoredrdatalibrary).
pip install qs2pyfrom qs2io import qd_read, qd_save, qs_read, qs_save, rds_read, rds_save
qd_obj = qd_read("data.qdata")
qd_pd = qd_read("data.qdata", dataframe_backend="pandas")
qd_pl = qd_read("data.qdata", dataframe_backend="polars")
qs_obj = qs_read("data.qs2")
rds_obj = rds_read("data.rds")
qd_save({"x": [1, 2, 3]}, "out.qdata")
qs_save({"x": [1, 2, 3]}, "out.qs2")
rds_save({"x": [1, 2, 3]}, "out.rds")For qdata, dataframe output can be switched from pandas to polars.
qdata files are decompressed and translated via code in this library. The translation spec is documented in:
qs2 uses the same outer format as qdata but object translation is delegated to the vendored rdata package.
At a high level, the qdata path supports:
- numeric, logical, complex, character, raw, and
NULL - nested lists
- NumPy arrays, including masked integer/logical arrays
- pandas and polars data frames
- shape and label upgrades through
dim,names, anddimnames xarray.DataArrayfor labeled array round-tripping- date/time and duration mappings for the supported qdata subset
qdataonly covers the qdata-supported subset of R object types. It is not a general replacement for arbitrary R serialization.qs2/RDStranslation usesrdatawhich may also have its own limitations.