coa-project / pycoa

pycoa Python source code
MIT License
18 stars 0 forks source link

bug with get #237

Closed NoamXD8 closed 3 months ago

NoamXD8 commented 3 months ago

pycoa.get(output='pandas', which='cur_hosp')

cur_hosp EXISTS in the database, that's why it's weird


KeyError Traceback (most recent call last) File ~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py:3621, in Index.get_loc(self, key, method, tolerance) 3620 try: -> 3621 return self._engine.get_loc(casted_key) 3622 except KeyError as err:

File pandas/_libs/index.pyx:136, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/index.pyx:163, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:5198, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:5206, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'cur_hosp'

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last) Cell In[24], line 1 ----> 1 pycoa.get(output='pandas', which='cur_hosp')

File ~/Desktop/pycoa/coabook/../coa/front.py:480, in Front.chartsinput_deco..wrapper(self, **kwargs) 478 input_field = which 479 for i in which: --> 480 tmp = self._db.get_stats(input_field=inputfield, which=i, where=where, option=option) 481 if len(which)>1: 482 tmp = tmp.rename(columns={'daily':'daily'+i,'weekly':'weekly_'+i})

File ~/Desktop/pycoa/coabook/../coa/covid19.py:289, in DataBase.get_stats(self, **kwargs) 286 kwargs['which'] = mypycoapd.columns[2] 287 #if kwargs['which'] not in self.dbfullinfo.get_available_keywords(): 288 # raise CoaKeyError(kwargs['which']+' this value is not available in this db, please check !') --> 289 mainpandas = return_nonan_dates_pandas(mypycoapd,kwargs['which']) 290 #while for last date all values are nan previous date 291 else: 292 mypycoapd=kwargs['input']

File ~/Desktop/pycoa/coabook/../coa/tools.py:314, in return_nonan_dates_pandas(df, field) 312 j = 0 313 while (boolval): --> 314 boolval = df.loc[df.date == (watchdate - dt.timedelta(days=j))][field].dropna().empty 315 j += 1 316 df = df.loc[df.date <= watchdate - dt.timedelta(days=j - 1)]

File ~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py:3505, in DataFrame.getitem(self, key) 3503 if self.columns.nlevels > 1: 3504 return self._getitem_multilevel(key) -> 3505 indexer = self.columns.get_loc(key) 3506 if is_integer(indexer): 3507 indexer = [indexer]

File ~/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py:3623, in Index.get_loc(self, key, method, tolerance) 3621 return self._engine.get_loc(casted_key) 3622 except KeyError as err: -> 3623 raise KeyError(key) from err 3624 except TypeError: 3625 # If we have a listlike key, _check_indexing_error will raise 3626 # InvalidIndexError. Otherwise we fall through and re-raise 3627 # the TypeError. 3628 self._check_indexing_error(key)

KeyError: 'cur_hosp'

NoamXD8 commented 3 months ago

pycoa.get(output='pandas', which='tot_cases')

but it's working with tot_cases, very weird

tjbtjbtjb commented 3 months ago

Which db ?

odadoun commented 3 months ago

@tjbtjbtjb it was for govcy (Chypre) I have forced the cumul data to be int32 ... bug fixed