hydromt.data_adapter.DataFrameAdapter#

class hydromt.data_adapter.DataFrameAdapter(path, driver=None, filesystem='local', nodata=None, rename={}, unit_mult={}, unit_add={}, meta={}, **kwargs)[source]#

Initiates data adapter for 2D tabular data.

This object contains all properties required to read supported files into a pandas.DataFrame(). In addition it keeps meta data to be able to reproduce which data is used.

Parameters:
  • path (str, Path) – Path to data source.

  • driver ({'csv', 'xlsx', 'xls', 'fwf'}, optional) – Driver to read files with, for ‘csv’ read_csv(), for {‘xlsx’, ‘xls’} read_excel(), and for ‘fwf’ read_fwf(). By default the driver is inferred from the file extension and falls back to ‘csv’ if unknown.

  • filesystem ({'local', 'gcs', 's3'}, optional) – Filesystem where the data is stored (local, cloud, http etc.). By default, local.

  • nodata ((dictionary) float, int, optional) – Missing value number. Only used if the data has no native missing value. Multiple nodata values can be provided in a list and differentiated between dataframe columns using a dictionary with variable (column) keys. The nodata values are only applied to columns with numeric data.

  • rename (dict, optional) – Mapping of native column names to output column names as required by hydroMT.

  • unit_mult (dict, optional) – Scaling multiplication and addition to change to map from the native data unit to the output data unit as required by hydroMT.

  • unit_add (dict, optional) – Scaling multiplication and addition to change to map from the native data unit to the output data unit as required by hydroMT.

  • meta (dict, optional) – Metadata information of dataframe, prefably containing the following keys: {‘source_version’, ‘source_url’, ‘source_license’, ‘paper_ref’, ‘paper_doi’, ‘category’}

  • **kwargs – Additional key-word arguments passed to the driver.

__init__(path, driver=None, filesystem='local', nodata=None, rename={}, unit_mult={}, unit_add={}, meta={}, **kwargs)[source]#

Initiates data adapter for 2D tabular data.

This object contains all properties required to read supported files into a pandas.DataFrame(). In addition it keeps meta data to be able to reproduce which data is used.

Parameters:
  • path (str, Path) – Path to data source.

  • driver ({'csv', 'xlsx', 'xls', 'fwf'}, optional) – Driver to read files with, for ‘csv’ read_csv(), for {‘xlsx’, ‘xls’} read_excel(), and for ‘fwf’ read_fwf(). By default the driver is inferred from the file extension and falls back to ‘csv’ if unknown.

  • filesystem ({'local', 'gcs', 's3'}, optional) – Filesystem where the data is stored (local, cloud, http etc.). By default, local.

  • nodata ((dictionary) float, int, optional) – Missing value number. Only used if the data has no native missing value. Multiple nodata values can be provided in a list and differentiated between dataframe columns using a dictionary with variable (column) keys. The nodata values are only applied to columns with numeric data.

  • rename (dict, optional) – Mapping of native column names to output column names as required by hydroMT.

  • unit_mult (dict, optional) – Scaling multiplication and addition to change to map from the native data unit to the output data unit as required by hydroMT.

  • unit_add (dict, optional) – Scaling multiplication and addition to change to map from the native data unit to the output data unit as required by hydroMT.

  • meta (dict, optional) – Metadata information of dataframe, prefably containing the following keys: {‘source_version’, ‘source_url’, ‘source_license’, ‘paper_ref’, ‘paper_doi’, ‘category’}

  • **kwargs – Additional key-word arguments passed to the driver.

Methods

__init__(path[, driver, filesystem, nodata, ...])

Initiates data adapter for 2D tabular data.

get_data([variables, time_tuple, logger])

Returns a DataFrame, optionally sliced by time and variables, based on the properties of this DataFrameAdapter.

get_filesystem(**kwargs)

Return an initialised filesystem object based on self.filesystem and **kwargs

resolve_paths([time_tuple, variables, ...])

Resolve {year}, {month} and {variable} keywords in self.path based on 'time_tuple' and 'variables' arguments

summary()

Returns a dictionary summary of the data adapter.

to_dict()

Returns a dictionary view of the data source.

to_file(data_root, data_name[, driver, ...])

Save dataframe slice to file.

Attributes

data_type