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

Error with the 'feature' column when creating a databunch #1

Closed
vrodriguezf opened this issue Oct 4, 2019 · 1 comment
Closed

Error with the 'feature' column when creating a databunch #1

vrodriguezf opened this issue Oct 4, 2019 · 1 comment

Comments

@vrodriguezf
Copy link
Contributor

vrodriguezf commented Oct 4, 2019

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!

@vrodriguezf vrodriguezf changed the title Unexpected error: You have NaN values in column(s) {cols} of your dataframe, please fix it. Error with the 'feature' column when creating a databunch Oct 4, 2019
@vrodriguezf
Copy link
Contributor Author

Hi,

The error is caused because I was not including the feature column into the values of the cols parameter. Fixed now.

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

1 participant