move-coop / parsons

A python library of connectors for the progressive community.
https://www.parsonsproject.org/
Other
257 stars 125 forks source link

Enhancement: Parsons Table: added rename_columns for multiple cols #919

Closed mkrausse-ggtx closed 8 months ago

mkrausse-ggtx commented 8 months ago

This pull request introduces a new method, rename_columns, to the ETL process. This method allows for the renaming of multiple columns at once in a Parsons Table.

The rename_columns method takes a dictionary as an argument (column_map), where the keys represent the current column names and the values represent the new column names. The method checks if the old column name exists and if the new column name does not already exist in the table. If these conditions are met, the method uses the underlying petl.rename function to perform the renaming operation.

The method returns the updated Parsons Table and also updates the self.table attribute of the class instance.

Unit tests have been added to ensure the rename_columns method works as expected and handles edge cases appropriately. These tests cover scenarios such as renaming columns with a valid column map, renaming only some columns, and attempting to rename a column that does not exist or to a name that already exists.

This enhancement provides a more efficient way to rename multiple columns, improving the flexibility and usability of the ETL process.

shaunagm commented 8 months ago

Why did you close this? Do you need help updating your PR?

mkrausse-ggtx commented 8 months ago

Why did you close this? Do you need help updating your PR?

Looks like when I tried to rename the branch to the naming convention I'm trying to keep, it closed it.