File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,9 @@ def add_geocode(
305
305
)
306
306
307
307
# state codes are all stored in one table
308
- if new_code in state_codes :
308
+ if from_code in state_codes and new_code in state_codes :
309
+ crosswalk = self ._load_crosswalk (from_code = "state" , to_code = "state" )
310
+ elif new_code in state_codes :
309
311
crosswalk = self ._load_crosswalk (from_code = from_code , to_code = "state" )
310
312
crosswalk = crosswalk .rename (
311
313
columns = {from_code : from_col , new_code : new_col }
Original file line number Diff line number Diff line change @@ -382,6 +382,11 @@ def test_add_geocode(self):
382
382
new_data2 = gmpr .add_geocode (new_data , "state_code" , "hhs_region_number" )
383
383
assert new_data2 ["hhs_region_number" ].unique ().size == 2
384
384
385
+ # state_name -> state_id
386
+ new_data = gmpr .add_geocode (self .zip_data , "zip" , "state_name" )
387
+ new_data2 = gmpr .add_geocode (new_data , "state_name" , "state_id" )
388
+ assert new_data2 .shape == (12 , 6 )
389
+
385
390
# fips -> nation
386
391
new_data = gmpr .replace_geocode (self .fips_data_5 , "fips" , "nation" )
387
392
assert new_data .equals (
You can’t perform that action at this time.
0 commit comments