Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1pt] PR: Add index to aggregated crosswalk table #1066

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
All notable changes to this project will be documented in this file.
We follow the [Semantic Versioning 2.0.0](http://semver.org/) format.


## v4.4.9.2 - 2024-02-02 - [PR#1066](https://github.com/NOAA-OWP/inundation-mapping/pull/1066)

Adds an index to the aggregated `crosswalk_table.csv`. The index is a consecutive integer that starts at 1. Columns have been reordered, renamed, and sorted.

### Changes

`tools/combine_crosswalk_tables.py`: Adds index and sorts and renames columns

<br/><br/>

## v4.4.9.1 - 2024-02-02 - [PR#1073](https://github.com/NOAA-OWP/inundation-mapping/pull/1073)

Dependabot requested two fixes. One for an upgrade to pillow [#1068](https://github.com/NOAA-OWP/inundation-mapping/pull/1068) and the other for juypterlab #[1067 ](https://github.com/NOAA-OWP/inundation-mapping/pull/1067)
Expand Down
12 changes: 11 additions & 1 deletion tools/combine_crosswalk_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def combine_crosswalk_tables(data_directory, output_filename):
filename, usecols=['HUC', 'HydroID', 'feature_id', 'LakeID'], dtype={'HUC': str}
)
file_df = file_df.drop_duplicates()
file_df = file_df.rename(columns={'HUC': 'huc8'})
file_df['BranchID'] = os.path.split(os.path.dirname(filename))[1]

dfs.append(file_df)
Expand All @@ -32,6 +31,17 @@ def combine_crosswalk_tables(data_directory, output_filename):
if len(dfs) > 1:
df = pd.concat(dfs)

df = df.rename(
columns={'HUC': 'huc8', 'HydroID': 'hydro_id', 'LakeID': 'lake_id', 'BranchID': 'branch_id'}
)

df = df.sort_values(by=['feature_id', 'huc8', 'branch_id', 'hydro_id'])

df = df.reset_index(drop=True)
df['hand_id'] = df.index + 1

df = df[['hand_id', 'feature_id', 'huc8', 'branch_id', 'hydro_id', 'lake_id']]

df.to_csv(output_filename, index=False)


Expand Down
Loading