glamod / glamod-ingest

Database preparation and ingestion for GLAMOD
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

cdm-lens: modify `_map_values()` to use `DataFrame.replace()` #26

Closed agstephens closed 4 years ago

agstephens commented 4 years ago
    def _map_values(self, df):
        mappers = _get_mappers()
        found_cols = [_ for _ in df.columns]

        for col, mapper in mappers:
            if col in found_cols:
#                log.warn(f'Mapping: {col}, with {mapper}')
                df[col].replace(mapper, inplace=True)

Test that output is identical is we use:

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.replace.html

agstephens commented 4 years ago

Tested and implemented. The resulting DF is the same.