From c6ff5494df3cab456545354ca80cbfc9db09c346 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Fri, 1 Mar 2019 17:09:56 +1100 Subject: [PATCH] Add workaround for bores with duplicate IDs --- waternsw_grabber/waternsw_grabber.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/waternsw_grabber/waternsw_grabber.py b/waternsw_grabber/waternsw_grabber.py index c980b7f..5bb1959 100644 --- a/waternsw_grabber/waternsw_grabber.py +++ b/waternsw_grabber/waternsw_grabber.py @@ -324,8 +324,15 @@ def extract_definitions(input_dir, output_dir): sites = sites.set_index('ID') # Get basin from master site dataframe - sites['Basin name'] = basins.loc[sites.index, 'Basin name'] - sites['Basin code'] = basins.loc[sites.index, 'Basin code'] + try: + sites['Basin name'] = basins.loc[sites.index, 'Basin name'] + sites['Basin code'] = basins.loc[sites.index, 'Basin code'] + except ValueError: + # FIXME: Some bores have duplicate IDs! + # Get basin name from input directory + sites['Basin name'] = input_dir + basin_idx = basins['Basin name'] == input_dir + sites['Basin code'] = basins.loc[basin_idx, 'Basin code'].values[0] # Save variable definitions variables = pd.DataFrame(