Skip to content

Avoid DataFrame mutation #61

@JulesBlm

Description

@JulesBlm

Some functions like map_to_brgi_db mutate the DataFrame that is passed in. This causes an error when calling some function twice, for example:

from bedrock_ge.gi.mapper import map_to_brgi_db
from bedrock_ge.gi.ags import ags_to_brgi_db_mapping

brgi_mapping_1 = ags_to_brgi_db_mapping("file1.ags", projected_crs)

brgi_db_1 = map_to_brgi_db(brgi_mapping_1)
brgi_db_2 = map_to_brgi_db(brgi_mapping_1) # ValueError(f"cannot insert {column}, already exists") ValueError: cannot insert project_uid, already exists

Suggested Fix

We should avoid mutation by copying the passed in DataFrame, and optionally add an optional inplace parameter that is set to False by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions