Skip to content

Commit 49b3283

Browse files
authored
Merge pull request #26 from QuantGov/clusters
0.4.4
2 parents 3d61149 + 9046a28 commit 49b3283

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

regcensus/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'list_dates',
1414
'list_document_types',
1515
'list_agencies',
16+
'list_clusters',
1617
'list_jurisdictions',
1718
'list_industries'
1819
]
@@ -32,6 +33,7 @@
3233
list_dates,
3334
list_document_types,
3435
list_agencies,
36+
list_clusters,
3537
list_jurisdictions,
3638
list_industries
3739
)

regcensus/api.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def get_values(series, jurisdiction, date, documentType=None, summary=True,
14-
dateIsRange=True, country=False, agency=None,
14+
dateIsRange=True, country=False, agency=None, cluster=None,
1515
industry=None, filtered=True, industryLevel=None, version=None,
1616
download=False, verbose=0):
1717
"""
@@ -84,6 +84,12 @@ def get_values(series, jurisdiction, date, documentType=None, summary=True,
8484
elif agency:
8585
url_call += f'&agency={agency}'
8686

87+
# If multiple clusters are given, parses the list into a string
88+
if type(cluster) == list:
89+
url_call += f'&cluster={",".join(str(i) for i in cluster)}'
90+
elif cluster:
91+
url_call += f'&cluster={cluster}'
92+
8793
# If multiple industries are given, parses the list into a string
8894
if type(industry) == list:
8995
url_call += f'&label={",".join(str(i) for i in industry)}'
@@ -376,6 +382,17 @@ def list_agencies(jurisdictionID=None, keyword=None):
376382
for a in json if a["agencyName"]}.items()))
377383

378384

385+
def list_clusters():
386+
"""
387+
Returns: dictionary containing names of clusters and associated IDs
388+
"""
389+
url_call = URL + '/clusters'
390+
json = requests.get(url_call).json()
391+
return dict(sorted({
392+
a["clusterName"]: a["agencyCluster"]
393+
for a in json if a["clusterName"]}.items()))
394+
395+
379396
def list_jurisdictions():
380397
"""
381398
Returns: dictionary containing names of jurisdictions and associated IDs

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='regcensus',
7-
version='0.4.3',
7+
version='0.4.4',
88
description='Python package for accessing data from the QuantGov API',
99
url='https://github.com/QuantGov/regcensus-api-python',
1010
author='QuantGov',

0 commit comments

Comments
 (0)