Skip to content

Commit f09ad8b

Browse files
authored
Merge pull request #4 from QuantGov/documentation_update
Documentation update and documentType option in get_documents()
2 parents dcf29e5 + 7dc80ad commit f09ad8b

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,24 @@ RegCensus API defines a number of periods depending on the series. For example,
3232
There are six helper functions to retrieve information about these key components of regdata. These functions provider the following information: topics, documents, jurisdictions, series, agencies, and years with data. The list functions begin with __list__. For example, to view the list of topics call __list_topics__. When an topic id parameter is supplied, the function returns the details about a specific topic.
3333

3434
```
35-
rc.list_topics()
35+
rc.list_document_subtype()
3636
```
3737

38-
Each topic comprises one or more *series*. The __list_series__ function returns the list of all series when no series id is provided.
38+
Each subtype comprises one or more *series*. The __list_series__ function returns the list of all series when no series id is provided. This call is a great place to start if you are looking for data based on a **topic** first.
3939

40-
There are other helper functions that give you a tour around RegData. To see the jurisdictions with data in RegData, call __list_jurisdiction__. This function returns the complete list in a list format.
4140

4241
```
4342
rc.list_jurisdictions(jurisdictionID = 38)
4443
```
44+
Just like the above function call, listing the jurisdictions is another great place to start. If you are looking for data for a specifc jurisdiction(s), this function
45+
will return the jurisdiction_id for all jurisdiction, which is key for retrieving data on any individual jurisdiction.
4546

46-
The __get_series_period__ function returns a list of all seriesa and the years with data available.
47+
The __get_periods__ function returns a list of all seriesa and the years with data available.
4748

4849
The output from this function can serve as a reference for the valid values that can be passed to parameters in the __get_values__ function. The number of records returned is the unique combination of series and jurisdictions that are available in RegData. The function takes the optional argument jurisdiction id.
4950

5051
```
51-
rc.get_series_period(jurisdictionID = 38)
52+
rc.get_periods(jurisdictionID = 38)
5253
```
5354

5455
## Metadata
@@ -80,6 +81,16 @@ The __get_industries__ function returns a data frame of industries with data in
8081
rc.get_industries(38)
8182
```
8283

84+
### Documents
85+
86+
The __get_documents__ function returns a data frame with metadata for document-level data. The fucntion takes two parameters, jurisdictionID (required) and documentType (default value of 3, which is "all regulations").
87+
88+
The following line will get metadata for documents associated with U.S. Federal healthcare regulations.
89+
90+
```
91+
rc.get_documents(jurisdictionID = 38, documentType = 1)
92+
```
93+
8394
## Values
8495

8596
The __get_values__ function is the primary function for obtaining RegData from the RegCensus API. The function takes the following parameters:

regcensus/api.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_values(series, jurisdiction, date, filtered=True, summary=True,
2222
date: Year(s) of data
2323
summary (optional): Return summary instead of document level data
2424
filtered (optional): Exclude poorly-performing industry results
25-
documentType (optional): Type of document
25+
documentType (optional): ID for type of document
2626
agency (optional): Agency ID
2727
industry (optional): Industry code using the jurisdiction-specific
2828
coding system (use 'all' for all industries)
@@ -216,10 +216,21 @@ def get_industries(jurisdictionID):
216216
return clean_columns(output)
217217

218218

219-
def get_documents(jurisdictionID):
219+
def get_documents(jurisdictionID, documentType=3):
220+
"""
221+
Get metadata for documents available in a specific jurisdiction, optional
222+
filtering by document type (see list_document_types() for options)
223+
224+
Args:
225+
jurisdictionID: ID for the jurisdiction
226+
documentType (optional): ID for type of document
227+
228+
Returns: pandas dataframe with the metadata
229+
"""
220230
output = pd.io.json.json_normalize(
221231
requests.get(
222-
URL + f'/documents?jurisdiction={jurisdictionID}&documentType=3'
232+
URL + (f'/documents?jurisdiction={jurisdictionID}&'
233+
f'documentType={documentType}')
223234
).json())
224235
return clean_columns(output)
225236

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.1.2',
7+
version='0.1.3',
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)