Skip to content

Commit 51fef65

Browse files
authored
Merge pull request #139 from thedavidhackett/master
Add support for 2022 ACS Data
2 parents 76c7310 + cdeeac3 commit 51fef65

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ Datasets
6767

6868
For each dataset, the first year listed is the default.
6969

70-
* acs5: `ACS 5 Year Estimates <https://www.census.gov/data/developers/data-sets/acs-5year.html>`_ (2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009)
70+
* acs5: `ACS 5 Year Estimates <https://www.census.gov/data/developers/data-sets/acs-5year.html>`_ (2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009)
7171
* acs3: `ACS 3 Year Estimates <https://www.census.gov/data/developers/data-sets/acs-3year.html>`_ (2013, 2012)
72-
* acs1: `ACS 1 Year Estimates <https://www.census.gov/data/developers/data-sets/acs-1year.html>`_ (2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
73-
* acs5dp: `ACS 5 Year Estimates, Data Profiles <https://www.census.gov/data/developers/data-sets/acs-5year.html>`_ (2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009)
72+
* acs1: `ACS 1 Year Estimates <https://www.census.gov/data/developers/data-sets/acs-1year.html>`_ (2022, 2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
73+
* acs5dp: `ACS 5 Year Estimates, Data Profiles <https://www.census.gov/data/developers/data-sets/acs-5year.html>`_ (2022, 2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009)
7474
* acs3dp: `ACS 3 Year Estimates, Data Profiles <https://www.census.gov/data/developers/data-sets/acs-3year.html>`_ (2013, 2012)
75-
* acs1dp: `ACS 1 Year Estimates, Data Profiles <https://www.census.gov/data/developers/data-sets/acs-1year.html>`_ (2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
76-
* acs5st: `ACS 5 Year Estimates, Subject Tables <https://www.census.gov/data/developers/data-sets/acs-5year.html>`_ (2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009)
75+
* acs1dp: `ACS 1 Year Estimates, Data Profiles <https://www.census.gov/data/developers/data-sets/acs-1year.html>`_ (2022, 2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
76+
* acs5st: `ACS 5 Year Estimates, Subject Tables <https://www.census.gov/data/developers/data-sets/acs-5year.html>`_ (2022, 2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009)
7777
* sf1: `Census Summary File 1 <https://www.census.gov/data/datasets/2010/dec/summary-file-1.html>`_ (2010)
7878
* pl: `Redistricting Data Summary File <https://www.census.gov/programs-surveys/decennial-census/about/rdo/summary-files.2020.html>`_ (2020, 2010, 2000)
7979

census/core.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,13 @@ def combined_statistical_area(self, fields, csa, **kwargs):
292292
return self.get(fields, geo={
293293
'for': 'combined statistical area:{}'.format(str(csa)),
294294
}, **kwargs)
295+
296+
@supported_years()
297+
def msa(self, fields, msa, **kwargs):
298+
return self.get(fields, geo={
299+
'for': ('metropolitan statistical area/' +
300+
'micropolitan statistical area:{}'.format(msa)),
301+
}, **kwargs)
295302

296303
class ACSClient(Client):
297304

@@ -320,7 +327,7 @@ def get(self, *args, **kwargs):
320327

321328
class ACS5Client(ACSClient):
322329

323-
default_year = 2021
330+
default_year = 2022
324331
dataset = 'acs5'
325332

326333
years = (2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009)
@@ -352,7 +359,7 @@ def state_county_blockgroup(self, fields, state_fips, county_fips,
352359
geo['in'] += ' tract:{}'.format(tract)
353360
return self.get(fields, geo=geo, **kwargs)
354361

355-
@supported_years(2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
362+
@supported_years(2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
356363
def zipcode(self, fields, zcta, **kwargs):
357364
warnings.warn(
358365
"zipcode has been deprecated; use state_zipcode instead",
@@ -363,7 +370,7 @@ def zipcode(self, fields, zcta, **kwargs):
363370

364371
return self.state_zipcode(fields, state_fips, zcta, **kwargs)
365372

366-
@supported_years(2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
373+
@supported_years(2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011)
367374
def state_zipcode(self, fields, state_fips, zcta, **kwargs):
368375
year = kwargs.get('year', self.default_year)
369376
geo = {
@@ -415,10 +422,10 @@ class ACS3DpClient(ACS3Client):
415422

416423
class ACS1Client(ACSClient):
417424

418-
default_year = 2021
425+
default_year = 2022
419426
dataset = 'acs1'
420427

421-
years = (2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005)
428+
years = (2022, 2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005)
422429

423430
@supported_years()
424431
def state_county_subdivision(self, fields, state_fips,
@@ -433,7 +440,7 @@ class ACS1DpClient(ACS1Client):
433440

434441
dataset = 'acs1/profile'
435442

436-
years = (2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012)
443+
years = (2022, 2021, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012)
437444

438445

439446
class SF1Client(Client):

census/tests/test_census.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
'place': '31175',
5151
'district': '06', # for old `state_district` calling.
5252
'congressional_district': '06',
53-
'legislative_district': '07',
53+
'legislative_district': '06',
5454
'zcta': '20877',
5555
'msa': '47900',
5656
'csa': '548',
@@ -133,9 +133,6 @@ class TestEndpoints(CensusTestCase):
133133

134134
def check_endpoints(self, client_name, tests, **kwargs):
135135

136-
if kwargs:
137-
tests = ((k, kwargs.get(k, v)) for k, v in tests)
138-
139136
client = self.client(client_name)
140137
fields = ('NAME',)
141138

@@ -144,7 +141,7 @@ def check_endpoints(self, client_name, tests, **kwargs):
144141
msg = '{}.{}'.format(client_name, method_name)
145142

146143
method = getattr(client, method_name)
147-
data = method(fields, **TEST_DATA)
144+
data = method(fields, **TEST_DATA, **kwargs)
148145
self.assertTrue(data, msg)
149146
self.assertEqual(data[0]['NAME'], expected, msg)
150147
time.sleep(0.2)
@@ -164,19 +161,19 @@ def test_acs5(self):
164161
('state_county_subdivision',
165162
'District 9, Montgomery County, Maryland'),
166163
('state_county_tract',
167-
'Census Tract 7007.06, Montgomery County, Maryland'),
164+
'Census Tract 7007.06; Montgomery County; Maryland'),
168165
('state_county_blockgroup',
169-
('Block Group 1, Census Tract 7007.06, '
170-
'Montgomery County, Maryland')),
166+
('Block Group 1; Census Tract 7007.06; '
167+
'Montgomery County; Maryland')),
171168
('state_place', 'Gaithersburg city, Maryland'),
172169
('state_district',
173-
'Congressional District 6 (116th Congress), Maryland'),
170+
'Congressional District 6 (118th Congress), Maryland'),
174171
('state_congressional_district',
175-
'Congressional District 6 (116th Congress), Maryland'),
172+
'Congressional District 6 (118th Congress), Maryland'),
176173
('state_legislative_district_upper',
177-
'State Senate District 7 (2018), Maryland'),
174+
'State Senate District 6 (2022), Maryland'),
178175
('state_legislative_district_lower',
179-
'State Legislative District 7 (2018), Maryland'),
176+
'State Legislative District 6 (2022), Maryland'),
180177
('state_zipcode', 'ZCTA5 20877'),
181178
)
182179

@@ -201,9 +198,9 @@ def test_acs5_previous_years(self):
201198
('state_congressional_district',
202199
'Congressional District 6 (116th Congress), Maryland'),
203200
('state_legislative_district_upper',
204-
'State Senate District 7 (2018), Maryland'),
201+
'State Senate District 6 (2018), Maryland'),
205202
('state_legislative_district_lower',
206-
'State Legislative District 7 (2018), Maryland'),
203+
'State Legislative District 6 (2018), Maryland'),
207204
('state_zipcode', 'ZCTA5 20877'),
208205
)
209206

@@ -215,7 +212,7 @@ def test_acs5st(self):
215212
('us', 'United States'),
216213
('state', 'Maryland'),
217214
('state_congressional_district',
218-
'Congressional District 6 (116th Congress), Maryland'),
215+
'Congressional District 6 (118th Congress), Maryland'),
219216
)
220217

221218
self.check_endpoints('acs5st', tests)
@@ -226,7 +223,7 @@ def test_acs1dp(self):
226223
('us', 'United States'),
227224
('state', 'Maryland'),
228225
('state_congressional_district',
229-
'Congressional District 6 (116th Congress), Maryland'),
226+
'Congressional District 6 (118th Congress), Maryland'),
230227
)
231228

232229
self.check_endpoints('acs1dp', tests)
@@ -277,9 +274,9 @@ def test_pl(self):
277274
('state_congressional_district',
278275
'Congressional District 6 (116th Congress), Maryland'),
279276
('state_legislative_district_upper',
280-
'State Senate District 7 (2018), Maryland'),
277+
'State Senate District 6 (2018), Maryland'),
281278
('state_legislative_district_lower',
282-
'State Legislative District 7 (2018), Maryland'),
279+
'State Legislative District 6 (2018), Maryland'),
283280
)
284281

285282
self.check_endpoints('pl', tests)

0 commit comments

Comments
 (0)