Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'data.categories' have KeyError #4

Open
mcui123 opened this issue Apr 6, 2021 · 1 comment
Open

'data.categories' have KeyError #4

mcui123 opened this issue Apr 6, 2021 · 1 comment

Comments

@mcui123
Copy link

mcui123 commented Apr 6, 2021

Hi there,

I have successfully installed the package but encountered error while running the following sample code:

'''Sample Query of All Database Groups - Default Databases'''

import datapungi_fed as dpf

data = dpf.data() 

data.datasetlist()       
data.categories(125)   
data.releases()
data.series('GDP')
data.sources('1')   
data.tags(tag_names='monetary+aggregates;weekly')
data.geo(series_id='WIPCPI')
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-14-e09de8c1e98c> in <module>
----> 1 data.categories['category'](125)

~/opt/anaconda3/lib/python3.8/site-packages/datapungi_fed/driverCore.py in <lambda>(*args, **kwargs)
    104         '''
    105         fun  = functools.partial(queryFun,dbName)
--> 106         lfun = lambda *args,**kwargs: fun(**self.getQueryArgs(dbName,*args,**kwargs))
    107         #add quick user tips
    108         lfun.options = self.dbParams[dbName]['params']

~/opt/anaconda3/lib/python3.8/site-packages/datapungi_fed/driverCore.py in query(self, *args, **kwargs)
     96 
     97     def query(self,*args,**kwargs):
---> 98         return( self.ETDB.query(*args,**kwargs) )
     99 
    100     def selectDBQuery(self,queryFun,dbName):

~/opt/anaconda3/lib/python3.8/site-packages/datapungi_fed/driverCore.py in query(self, dbName, params, file_type, verbose, warningsOn)
    156         warningsList = ['countPassLimit']  # warn on this events.
    157         prefixUrl = self.dbParams[dbName]['urlSuffix']
--> 158         output = self.queryApiCleanOutput(prefixUrl, dbName, params, warningsList, warningsOn, verbose)
    159         return(output)
    160 

~/opt/anaconda3/lib/python3.8/site-packages/datapungi_fed/driverCore.py in queryApiCleanOutput(self, urlPrefix, dbName, params, warningsList, warningsOn, verbose)
    178 
    179         #clean data
--> 180         df_output,self._cleanCode = self.cleanOutput(dbName,query,retrivedData)
    181 
    182         #print warning if there is more data the limit to download

~/opt/anaconda3/lib/python3.8/site-packages/datapungi_fed/driverCore.py in cleanOutput(self, dbName, query, retrivedData)
    225          this generates self._cleanCode
    226         '''
--> 227         transformedOutput = self._transformData(self.dbGroup,dbName,self.dbParams,query,retrivedData)
    228         return(transformedOutput)
    229 

~/opt/anaconda3/lib/python3.8/site-packages/datapungi_fed/driverCore.py in __call__(self, dbGroup, dbName, dbParams, query, retrivedData)
    261             return( self.cleanOutputGeo(dbName,dbParams,query,retrivedData) )
    262         else:
--> 263             return( self.cleanOutput(dbName,dbParams,query,retrivedData) )
    264 
    265     def cleanOutput(self, dbName, dbParams,query, retrivedData): #categories, releases, sources, tags

~/opt/anaconda3/lib/python3.8/site-packages/datapungi_fed/driverCore.py in cleanOutput(self, dbName, dbParams, query, retrivedData)
    266         dataKey = dbParams[dbName]['json key']
    267         cleanCode = "df_output =  pd.DataFrame( retrivedData.json()['{}'] )".format(dataKey)
--> 268         df_output = pd.DataFrame(retrivedData.json()[dataKey])  # TODO: deal with xml
    269         warnings.filterwarnings("ignore", category=UserWarning)
    270         setattr(df_output, '_meta', dict(filter(lambda entry: entry[0] != dataKey, retrivedData.json().items())))

KeyError: 'categories'

I am wondering if I did anything wrong here that is causing the code to break? Much appreciation for your help!

@rcyost
Copy link

rcyost commented Jul 9, 2023

Initially, I have the same error. Looks like the package is not working and is no longer supported. I will see if I can debug and return with answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants