Skip to content

onehealth_db.duck_database module⚓︎

onehealth_db.duck_database ⚓︎

Functions:

  • file_to_dataframe

    Convert a netCDF/GRIB file to a pandas DataFrame.

  • import_data

    Import data from a CSV file into the DuckDB database.

Attributes:

DEFAULT_DB_PATH module-attribute ⚓︎

DEFAULT_DB_PATH = Path('data/onehealth.db')

file_to_dataframe ⚓︎

file_to_dataframe(file_path, columns='default')

Convert a netCDF/GRIB file to a pandas DataFrame.

Parameters:

  • file_path (Path) –

    The path to the file.

  • columns (Union[List[str], Literal['all', 'default']], default: 'default' ) –

    The columns to include in the DataFrame.

    If "all", all columns are included.

    If "default", default columns are included.

    If a list, only the specified columns are included.

Returns:

  • DataFrame

    pd.DataFrame: The DataFrame containing the data from the file.

import_data ⚓︎

import_data(data, db_path=None, table_name=None)

Import data from a CSV file into the DuckDB database.

Parameters:

  • data (DataFrame) –

    The DataFrame to import.

  • db_path (Path, default: None ) –

    The path to the DuckDB database file.

  • table_name (str, default: None ) –

    The name of the table to create in the database.