hydromt.data_catalog.drivers.DataFrameDriver#
- pydantic model hydromt.data_catalog.drivers.DataFrameDriver[source]#
Abstract Driver to read DataFrames.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- abstract read(uris: list[str], *, handle_nodata: NoDataStrategy = NoDataStrategy.RAISE, variables: str | List[str] | None = None) DataFrame[source]#
Read data from one or more URIs into a pandas DataFrame.
This abstract method defines the interface for all DataFrame-based drivers. Subclasses should implement data loading logic appropriate for the format being read.
- Parameters:
uris (
list[str]) – List of URIs to read data from. The driver decides how to handle multiple files.handle_nodata (
NoDataStrategy, optional) – Strategy to handle missing or empty data. Default is NoDataStrategy.RAISE.variables (
Variables | None, optional) – List of variable names (columns) to select from the source data. Default is None.
- Returns:
The loaded DataFrame.
- Return type:
pd.DataFrame
- abstract write(path: Path | str, data: DataFrame, *, write_kwargs: dict[str, Any] | None = None) Path[source]#
Write a pandas DataFrame to a file.
This abstract method defines the interface for writing DataFrames in all DataFrame-based drivers. Subclasses should implement logic appropriate for the target file format (e.g., CSV, Parquet, Excel).
- Parameters:
path (
Path | str) – Destination path or URI where the DataFrame should be written.data (
pd.DataFrame) – The DataFrame to be written to disk.write_kwargs (
dict[str,Any], optional) – Additional keyword arguments to pass to the underlying pandas write function (e.g., to_csv, to_excel, to_parquet). Default is None.
- Returns:
The path where the data was written.
- Return type:
Path