Skip to content

Instantly share code, notes, and snippets.

@prratek
Created December 3, 2018 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prratek/deb8c0627afb1df590d57aa38c50e60d to your computer and use it in GitHub Desktop.
Save prratek/deb8c0627afb1df590d57aa38c50e60d to your computer and use it in GitHub Desktop.
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-65-a21b1f7faa1d> in <module>
2 src = (ImageItemList.from_df(df=train_df, path=path, cols='Name', folder='train')
3 .split_by_valid_func(lambda o: o in val_n)
----> 4 .label_from_df(cols='Id'))
/opt/anaconda3/lib/python3.6/site-packages/fastai/data_block.py in _inner(*args, **kwargs)
346 self.train = ft(*args, **kwargs)
347 assert isinstance(self.train, LabelList)
--> 348 self.valid = fv(*args, **kwargs)
349 self.__class__ = LabelLists
350 self.process()
/opt/anaconda3/lib/python3.6/site-packages/fastai/data_block.py in label_from_df(self, cols, **kwargs)
199 "Label `self.items` from the values in `cols` in `self.xtra`."
200 labels = _maybe_squeeze(self.xtra.iloc[:,df_names_to_idx(cols, self.xtra)])
--> 201 return self.label_from_list(labels, **kwargs)
202
203 def label_const(self, const:Any=0, **kwargs)->'LabelList':
/opt/anaconda3/lib/python3.6/site-packages/fastai/data_block.py in label_from_list(self, labels, **kwargs)
191 "Label `self.items` with `labels` using `label_cls`"
192 labels = array(labels, dtype=object)
--> 193 label_cls = self.get_label_cls(labels, **kwargs)
194 y = label_cls(labels, path=self.path, **kwargs)
195 res = self._label_list(x=self, y=y)
/opt/anaconda3/lib/python3.6/site-packages/fastai/data_block.py in get_label_cls(self, labels, label_cls, sep, **kwargs)
181 if label_cls is not None: return label_cls
182 if self.label_cls is not None: return self.label_cls
--> 183 it = index_row(labels,0)
184 if sep is not None: return MultiCategoryList
185 if isinstance(it, (float, np.float32)): return FloatList
/opt/anaconda3/lib/python3.6/site-packages/fastai/core.py in index_row(a, idxs)
207 if isinstance(res,(pd.DataFrame,pd.Series)): return res.copy()
208 return res
--> 209 return a[idxs]
210
211 def func_args(func)->bool:
IndexError: index 0 is out of bounds for axis 0 with size 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment