Skip to content

csv.py

PandasCSV dataclass

Bases: IO[DataFrame]

IO to load from and save to CSV data using Pandas. Calls pd.read_csv and pd.write_csv under the hood.

Example:

>>> import pandas as pd
>>> from pathlib import Path
>>> from ordeq_pandas import PandasCSV
>>> csv = PandasCSV(
...     path=Path("path/to.csv")
... ).load(header="infer")  # doctest: +SKIP

Load behaviour is configured by with_load_options:

>>> csv = PandasCSV(
...     path=Path("path/to.csv")
... ).with_load_options(header="infer")

Save behaviour is configured by with_save_options:

>>> csv = PandasCSV(
...     path=Path("path/to.csv"),
... ).with_save_options(header=True)