Skip to main content

Small, typed data science helpers for serialization and dataframe-oriented record normalization.

Project description

dr-ds

Small, typed data science helpers for serialization and dataframe-oriented record normalization.

Install

uv add dr-ds

dr-ds currently targets Python 3.13+.

Included Helpers

dr_ds.serialization provides:

  • serialize_timestamp
  • utc_now_iso
  • to_jsonable
  • convert_large_ints
  • parse_jsonish
  • dump_json_atomic

dr_ds.parquet provides:

  • records_to_parquet_frame
  • parquet_frame_to_records

These helpers are aimed at a common pattern in data workflows:

  • start with list[dict[str, Any]] records
  • normalize nested JSON-like columns into strings for dataframe/parquet compatibility
  • recover those structured columns on read

Serialization Example

from pathlib import Path

from dr_ds.serialization import dump_json_atomic, to_jsonable

payload = to_jsonable(
    {
        "metrics": {"loss": 0.42},
        "tags": {"baseline", "v1"},
    }
)

dump_json_atomic(Path("summary.json"), payload)

Parquet Example

from dr_ds.parquet import parquet_frame_to_records, records_to_parquet_frame

records = [
    {
        "run_id": "abc123",
        "metrics": {"loss": 0.42, "token_count": 2**35},
    }
]

frame = records_to_parquet_frame(records, json_columns={"metrics"})
restored = parquet_frame_to_records(frame, json_columns={"metrics"})

records_to_parquet_frame prepares records for dataframe/parquet workflows. It does not write parquet files directly.

License

MIT

Development

Run the standard checks before committing:

uv run ruff format .
uv run ruff check .
uv run ty check
uv run pytest

Project details


Download files

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

Source Distribution

dr_ds-0.1.0.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

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

dr_ds-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file dr_ds-0.1.0.tar.gz.

File metadata

  • Download URL: dr_ds-0.1.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.0

File hashes

Hashes for dr_ds-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b53d894497ea0c244f53de26fed3d63f6c08d68f04e208e10ec20b566158f5d9
MD5 3918d100d0e78c859a66ad0a4024665e
BLAKE2b-256 27b9e9f2f05ae2e5d2021c43aa7e7e7d53c2db1fa475da08b554ce8069a79be8

See more details on using hashes here.

File details

Details for the file dr_ds-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dr_ds-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.0

File hashes

Hashes for dr_ds-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9e269aa91ed1e9d5abb98ccf04853512047627007e5c0a5fdb5dc4a16cba08a
MD5 1d79031b724419badcf70768e53752dc
BLAKE2b-256 ea9b80022d1c21c98dade49f23b41850e88fc635a70c4f140846d4ffcbb60982

See more details on using hashes here.

Supported by

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