Dataset creation on Socrata Error (cannot unpack non-iterable OutputSchema object)
aliciatb opened this issue · comments
ISSUE
When publishing new dataset with dataframe, it doesn't complete the publishing though the draft is successfully created with data.
CODE
from autocensus import Query
from autocensus.socrata import to_socrata
import os
import pandas as pd
query = Query(
estimate=5,
years=range(2018, 2019),
variables=['C16001_002E','C16001_003E','C16001_006E','C16001_009E','C16001_012E','C16001_015E','C16001_018E','C16001_021E','C16001_024E','C16001_027E','C16001_030E','C16001_033E','C16001_036E'],
for_geo='tract:*',
in_geo=['state:53', 'county:*'],
join_geography=True
)
data = query.run()
data.loc[:,'variable_label'] = 'No health insurance coverage'
data = data.drop(['difference','percent_change','centroid','geometry'], axis=1)
auth = (os.environ['SOCRATA_KEY_ID'], os.environ['SOCRATA_KEY_SECRET'])
to_socrata(
'alicia.data.socrata.com',
dataframe=data,
name='American Community Survey 5 Year Estimates - Washington State Census Tracts', # Optional
description='Language at Home (C16001)'# Optional
)
ERROR
TypeError Traceback (most recent call last)
in
22 dataframe=data,
23 name='American Community Survey 5 Year Estimates - Washington State Census Tracts', # Optional
---> 24 description='Language at Home (C16001)'# Optional
25 )
~/anaconda3/lib/python3.7/site-packages/autocensus/socrata.py in to_socrata(domain, dataframe, dataset_id, name, description, auth, open_in_browser)
125 name = name if name is not None else 'American Community Survey Data'
126 description = description if description is not None else ''
--> 127 revision = create_new_dataset(client, dataframe, name, description)
128 else:
129 revision = update_existing_dataset(client, dataframe, dataset_id)
~/anaconda3/lib/python3.7/site-packages/autocensus/socrata.py in create_new_dataset(client, dataframe, name, description)
75 name=name, description=description, attributionLink='https://api.census.gov'
76 ).df(dataframe)
---> 77 ok, output = prepare_output_schema(output)
78 ok, job = revision.apply(output_schema=output)
79 return revision
TypeError: cannot unpack non-iterable OutputSchema object
Thanks for flagging this. It looks like a socrata-py version issue — version 1.x of socrata-py has some breaking changes from earlier releases like 0.4.21, which is pinned in autocensus's dependencies. I'd say errors are to be expected when using a different major version of a dependency, but a good reminder to add support for socrata-py 1.x in the next autocensus release.