Skip to content

Commit 682c15b

Browse files
authored
v4.4.9.2 Add index to aggregated crosswalk table (#1066)
1 parent 85c77e9 commit 682c15b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

docs/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
All notable changes to this project will be documented in this file.
22
We follow the [Semantic Versioning 2.0.0](http://semver.org/) format.
33

4+
5+
## v4.4.9.2 - 2024-02-02 - [PR#1066](https://github.com/NOAA-OWP/inundation-mapping/pull/1066)
6+
7+
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.
8+
9+
### Changes
10+
11+
`tools/combine_crosswalk_tables.py`: Adds index and sorts and renames columns
12+
13+
<br/><br/>
14+
415
## v4.4.9.1 - 2024-02-02 - [PR#1073](https://github.com/NOAA-OWP/inundation-mapping/pull/1073)
516

617
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)

tools/combine_crosswalk_tables.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def combine_crosswalk_tables(data_directory, output_filename):
2222
filename, usecols=['HUC', 'HydroID', 'feature_id', 'LakeID'], dtype={'HUC': str}
2323
)
2424
file_df = file_df.drop_duplicates()
25-
file_df = file_df.rename(columns={'HUC': 'huc8'})
2625
file_df['BranchID'] = os.path.split(os.path.dirname(filename))[1]
2726

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

34+
df = df.rename(
35+
columns={'HUC': 'huc8', 'HydroID': 'hydro_id', 'LakeID': 'lake_id', 'BranchID': 'branch_id'}
36+
)
37+
38+
df = df.sort_values(by=['feature_id', 'huc8', 'branch_id', 'hydro_id'])
39+
40+
df = df.reset_index(drop=True)
41+
df['hand_id'] = df.index + 1
42+
43+
df = df[['hand_id', 'feature_id', 'huc8', 'branch_id', 'hydro_id', 'lake_id']]
44+
3545
df.to_csv(output_filename, index=False)
3646

3747

0 commit comments

Comments
 (0)