Skip to content

Commit 8ec9151

Browse files
authored
Merge pull request #33 from QuantGov/dev
code fixes & updated readme
2 parents 881c66f + 7209da2 commit 8ec9151

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ The following line will get you industry information for all 4-digit NAICS indus
9595
rc.get_industries(labellevel = 4)
9696
```
9797

98-
This line will get you information for the BEA industries (this function is temporarily disabled as of 1.0.0):
98+
This line will get you information for the NAICS industries (this function is temporarily disabled as of 1.0.0):
9999

100100
```
101-
rc.get_industries(labelsource = 'BEA')
101+
rc.get_industries(labelsource = 'NAICS')
102102
```
103103

104104
Like the __get_agencies__ function, the `keyword` argument may also be used. The following code snippet will return information for all 6-digit NAICS industries with the word "fishing" in the name (this function is temporarily disabled as of 1.0.0):
105105

106106
```
107-
rc.get_industries(keyword = 'fishing', codeLevel = 6)
107+
rc.get_industries(keyword = 'fishing', labellevel = 6)
108108
```
109109

110110
## Values
@@ -149,7 +149,7 @@ To obtain the restrictions for a specific agency (or agencies), the series id su
149149

150150
```
151151
# Identify all agencies
152-
rc.list_agencies(jurisdictionID)
152+
rc.list_agencies(jurisdictionID = 38)
153153
154154
# Call the get_values() for two agencies and series 13
155155
rc.get_values(series = 13, jurisdiction = 38, year = [2000, 2018], agency = [15918, 15921])
@@ -161,10 +161,10 @@ Some agency series may also have data by industry. For example, under the Total
161161

162162
Valid values for industries include the industry codes specified in the classification system obtained by calling the __get_industries(jurisdiction)__ function.
163163

164-
In the example below, the series 92 (Restrictions by Agency and Industry), we can request data for the two industries 111 and 33 by the following code snippet.
164+
In the example below, for the below series, we can request data for the two industries 111 and 33 by the following code snippet.
165165

166166
```
167-
rc.get_values(series = 92, jurisdiction = 38, time = [1990, 2000], industry = [111, 33], agency = 66)
167+
rc.get_values(series = [1,28,33,36], jurisdiction = 38, year = [1990, 2000], label = 111, agency = 0)
168168
```
169169

170170
### Document-Level Values
@@ -174,16 +174,16 @@ For most use-cases, our summary-level data will be enough. However, document-lev
174174
We can request the same data from above, but at the document level, using the following code snippet.
175175

176176
```
177-
rc.get_values(series = [1,2], jurisdiction = 38, date = ['2010-01-01', '2019-01-01'], summary=False)
177+
rc.get_values(series = [1,2], jurisdiction = 38, year = 2020, summary=False)
178178
```
179179

180180
Alternatively, we can use the __get_document_values__ function as in the following code snippet.
181181

182182
```
183-
rc.get_document_values(series = [1,2], jurisdiction = 38, date = ['2010-01-01', '2019-01-01'])
183+
rc.get_document_values(series = [1,2], jurisdiction = 38, year = 2019)
184184
```
185185

186-
Note that for document-level queries, a full date (not just the year) is often required. See the __get_series__ function for specifics by jurisdiction.
186+
See the __get_series__ function for specifics by jurisdiction.
187187

188188
### Version
189189

@@ -192,7 +192,7 @@ _This currently applies to the RegData U.S. Annual project only._
192192
As of version 0.2.4, a version parameter can be passed to the __get_values__ function to obtained data from past versions of data (currently only for the RegData U.S. Annual project). Available versions and their associated versionIDs can be obtained by using the __get_version__ function. If no version parameter is given, the most recent version will be returned. The following code snippet will return restrictions data for the 3.2 version of RegData U.S. Annual for the years 2010 to 2019.
193193

194194
```
195-
rc.get_values(series = 1, jurisdiction = 38, date = [2010, 2019], version = 1)
195+
rc.get_values(series = 1, jurisdiction = 38, year = [2010, 2019], version = 1)
196196
```
197197

198198
### Merging with Metadata
@@ -206,13 +206,13 @@ We can merge the agency data with the values data as in the code snippet below.
206206
```
207207
agencies = rc.get_agencies(jurisdictionID = 38)
208208
agency_by_industry = rc.get_values(
209-
series = 92,
209+
series = [1,28,33,36],
210210
jurisdiction = 38,
211-
time = [1990, 2000],
212-
industry = [111, 33],
213-
agency = [66, 111])
211+
year = [1990, 2000],
212+
label = 111,
213+
agency = 0)
214214
agency_restrictions_ind = agency_by_industry.merge(
215-
agencies, by='agency_id')
215+
agencies, on='agency_id')
216216
```
217217

218218
## Downloading Data
@@ -224,7 +224,7 @@ There are two different ways to download data retrieved from RegCensusAPI:
224224
2. As of version 0.2.0, the __get_values__ function includes a `download` argument, which allows the user to simply download a csv of the data in the same line as the API call. See below for an example of this call.
225225

226226
```
227-
rc.get_values(series = [1,2], jurisdiction = 38, date = [2010, 2019], download='regdata2010to2019.csv')
227+
rc.get_values(series = [1,28,33,36], jurisdiction = 38, year = [2010, 2019], download='regdata2010to2019.csv')
228228
```
229229

230230
[1]:https://api.quantgov.org/swagger-ui.html

regcensus/api.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ def get_values(series, jurisdiction, year, documentType=1, summary=True,
157157
url_call += f'&labelLevel={labellevel}'
158158

159159
# If multiple years are given, parses the list into a string
160+
if not summary and type(year) == list:
161+
print(
162+
'WARNING: document-level data is only returnable for a single '
163+
'year at a time. Returning the first year requested.'
164+
)
165+
year = year[0]
160166
if type(year) == list:
161167
# If dateIsRange, parses the list to include all years
162168
if dateIsRange and len(year) == 2:
@@ -231,7 +237,7 @@ def get_values(series, jurisdiction, year, documentType=1, summary=True,
231237
page += 1
232238
output = json_normalize(json.loads(requests.get(
233239
url_call + f'&page={page}').json()))
234-
full_output = full_output.append(output)
240+
full_output = pd.concat([full_output, output])
235241
output = full_output
236242

237243
# If download path is given, write csv instead of returning dataframe
@@ -251,6 +257,9 @@ def get_document_values(*args, **kwargs):
251257
252258
Simply returns get_values() with summary=False
253259
"""
260+
if type(kwargs["year"]) == list:
261+
print_error({"message" : "Only single year can be passed."})
262+
return
254263
return get_values(*args, **kwargs, summary=False)
255264

256265

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='1.0.0',
7+
version='1.0.1',
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)