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.1.tar.gz (23.3 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.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dr_ds-0.1.1.tar.gz
Algorithm Hash digest
SHA256 efa5babff59a38f3e7df728caeac83fc367b242bcd690808808a7de4bc2fab84
MD5 85291ada0ec04a95f8420564ff4dc75f
BLAKE2b-256 c59bfdf0534f20213b3568bdb3e784d725947a7fb4530870e8d82c6ecb7dd94a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dr_ds-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e95ce6d4c7611132eb58a9790f543bf67680ee18ed7f8f2ce8148166261beae9
MD5 64dc20a2c827471eac1ab2f271369328
BLAKE2b-256 947b6bbee4e7cfba56eea585a9ccaafa7e7775eda9a539ea18bee06e782a7e52

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