diff --git a/census/core.py b/census/core.py index df79064..5559a61 100644 --- a/census/core.py +++ b/census/core.py @@ -349,8 +349,20 @@ def state_county_blockgroup(self, fields, state_fips, county_fips, @supported_years(2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011) def zipcode(self, fields, zcta, **kwargs): + warnings.warn( + "zipcode has been deprecated; use state_zipcode instead", + DeprecationWarning + ) + + state_fips = kwargs.pop('state_fips') + + return self.state_zipcode(fields, state_fips, zcta, **kwargs) + + @supported_years(2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011) + def state_zipcode(self, fields, state_fips, zcta, **kwargs): return self.get(fields, geo={ 'for': 'zip code tabulation area:{}'.format(zcta), + 'in': 'state:{}'.format(state_fips), }, **kwargs) diff --git a/census/tests/test_census.py b/census/tests/test_census.py index 3360f5f..12fe6fc 100644 --- a/census/tests/test_census.py +++ b/census/tests/test_census.py @@ -164,7 +164,7 @@ def test_acs5(self): 'State Senate District 7 (2018), Maryland'), ('state_legislative_district_lower', 'State Legislative District 7 (2018), Maryland'), - ('zipcode', 'ZCTA5 20877'), + ('state_zipcode', 'ZCTA5 20877'), ) self.check_endpoints('acs5', tests)