Closed
Description
Hi,
I found a weird error when creating the databunch following the steps of the first notebook:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2656 try:
-> 2657 return self._engine.get_loc(key)
2658 except KeyError:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'feature'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
4 frames
<ipython-input-45-c74cce7b4c94> in <module>()
3 target_colname = 'target' # *
4 valid_pct = 0.2 # *
----> 5 db = (TimeSeriesList.from_df(df = df, path = '.', cols=df.columns.values[3:], feat='feature')
6 .split_by_rand_pct(valid_pct= valid_pct, seed=seed)
7 .label_from_df(cols=target_colname, label_cls=CategoryList)
/content/timeseriesAI/fastai_timeseries/exp/nb_TSBasicData.py in from_df(cls, df, path, cols, feat, processor, **kwargs)
204 assert inputs.isna().sum().sum(
205 ) == 0, f"You have NaN values in column(s) {cols} of your dataframe, please fix it."
--> 206 inputs = df2array(inputs, feat)
207 res = cls(
208 items=inputs,
/content/timeseriesAI/fastai_timeseries/exp/nb_TSBasicData.py in df2array(df, feat)
297 if feat is None:
298 return df.values[:, None]
--> 299 for i, ch in enumerate(df[feat].unique()):
300 data_i = df[df[feat] == ch].values[:, None]
301 if i == 0: data = data_i
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in __getitem__(self, key)
2925 if self.columns.nlevels > 1:
2926 return self._getitem_multilevel(key)
-> 2927 indexer = self.columns.get_loc(key)
2928 if is_integer(indexer):
2929 indexer = [indexer]
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2657 return self._engine.get_loc(key)
2658 except KeyError:
-> 2659 return self._engine.get_loc(self._maybe_cast_indexer(key))
2660 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
2661 if indexer.ndim > 1 or indexer.size > 1:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'feature'
Best!
Metadata
Metadata
Assignees
Labels
No labels