SDV icon indicating copy to clipboard operation
SDV copied to clipboard

KeyError: 'frame'

Open enthusiasmYuan opened this issue 3 years ago • 1 comments

Environment details

If you are already running SDV, please indicate the following details about the environment in which you are running it:

  • SDV version:master
  • Python version:3.9
  • Operating System:Windows

Problem description

Hello, today I have an incomprehensible error when I am using PAR for time series generation. sequence_index in my dataset is ”frame" (int type) that represents the number of timeframes, however, I have the following keyerror error when calling the function:

KeyError Traceback (most recent call last) File d:\Anaconda3\lib\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 d:\Anaconda3\lib\site-packages\pandas_libs\index.pyx:136, in pandas._libs.index.IndexEngine.get_loc()

File d:\Anaconda3\lib\site-packages\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: 'frame'

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

KeyError Traceback (most recent call last) e:\code\PAR\test copy.ipynb Cell 7 in <cell line: 1>() ----> 1 model.sample(1).head()

File ~\AppData\Roaming\Python\Python39\site-packages\sdv\timeseries\base.py:269, in BaseTimeseriesModel.sample(self, num_sequences, context, sequence_length) 266 context[column] = range(len(context)) ... 3626 # InvalidIndexError. Otherwise we fall through and re-raise 3627 # the TypeError. 3628 self._check_indexing_error(key)

KeyError: 'frame'

What I already tried

I tried the tutorial you provided and there were no errors.

enthusiasmYuan avatar Oct 05 '22 09:10 enthusiasmYuan

Hi @enthusiasmYuan, sorry to hear!

sequence_index in my dataset is ”frame" (int type) that represents the number of timeframes

There is an open bug where the PAR model crashes when sequence_index is type int -- it only seems to work with datetime. We're using #808 to track its fix and I've included some workarounds you can use in the meantime.

Let me know if this solves your issue!

npatki avatar Oct 05 '22 14:10 npatki

Hi @enthusiasmYuan,

I'm closing this issue off as a duplicate, since the sequence_index issue is likely the root cause.

If the workarounds do not work or you have any more thoughts, please feel free to reply and I will re-open this issue for discussion.

npatki avatar Oct 17 '22 21:10 npatki