geonature.core.imports.checks.dataframe.core

Functions

check_required_values(df, fields)

Check if required values are present in the dataframe.

check_counts(df, count_min_field, count_max_field[, ...])

Check if the value in the count_min_field is lower or equal to the value in the count_max_field

check_datasets(→ Set[str])

Check if datasets exist and are authorized for the user and import.

Module Contents

geonature.core.imports.checks.dataframe.core.check_required_values(df: pandas.DataFrame, fields: Dict[str, geonature.core.imports.models.BibFields])[source]

Check if required values are present in the dataframe.

Parameters

dfpandas.DataFrame

The dataframe to check.

fieldsDict[str, BibFields]

Dictionary of fields to check.

Yields

dict

Dictionary containing the error code, the column name and the invalid rows.

Notes

Field is mandatory if: ((field.mandatory AND NOT (ANY optional_cond is not NaN)) OR (ANY mandatory_cond is not NaN))

<=> ((field.mandatory AND ALL optional_cond are NaN ) OR (ANY mandatory_cond is not NaN))

geonature.core.imports.checks.dataframe.core.check_counts(df: pandas.DataFrame, count_min_field: str, count_max_field: str, default_count: int = None)[source]

Check if the value in the count_min_field is lower or equal to the value in the count_max_field

count_min_field | count_max_field |
————— | ————— |
0 | 2 | –> ok
2 | 0 | –> provoke an error

Parameters

dfpandas.DataFrame

The dataframe to check.

count_min_fieldBibField

The field containing the minimum count.

count_max_fieldBibField

The field containing the maximum count.

default_countobject, optional

The default count to use if a count is missing, by default None.

Yields

dict

Dictionary containing the error code, the column name and the invalid rows.

Returns

set

Set of columns updated.

geonature.core.imports.checks.dataframe.core.check_datasets(imprt: geonature.core.imports.models.TImports, df: pandas.DataFrame, uuid_field: geonature.core.imports.models.BibFields, id_field: geonature.core.imports.models.BibFields, module_code: str, object_code: str | None = None) Set[str][source]

Check if datasets exist and are authorized for the user and import.

Parameters

imprtTImports

Import to check datasets for.

dfpd.DataFrame

Dataframe to check.

uuid_fieldBibFields

Field containing dataset UUIDs.

id_fieldBibFields

Field to fill with dataset IDs.

module_codestr

Module code to check datasets for.

object_codeOptional[str], optional

Object code to check datasets for, by default None.

Yields

dict

Dictionary containing error code, column name and invalid rows.

Returns

Set[str]

Set of columns updated.