TextDatabunch.from_df gets keyerror

data_lm = TextDataBunch.from_df(’…/’,train_df=train_df,valid_df=val_df,text_cols=[‘text’],label_cols=[‘support_area’])

I get below error for the above line and also not very sure what to provide for path in this case?
Please help. Thank you.

KeyError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3062 try:
-> 3063 return self._engine.get_loc(key)
3064 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: 1

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)
in ()
----> 1 data_lm = TextDataBunch.from_df(’’,train_df=train_df,valid_df=val_df,text_cols=[‘text’],label_cols=[‘support_area’])

~\AppData\Roaming\Python\Python36\site-packages\fastai\text\data.py in from_df(cls, path, train_df, valid_df, test_df, tokenizer, vocab, **kwargs)
328 k_names = [‘max_vocab’, ‘min_freq’, ‘n_labels’, ‘txt_cols’, ‘label_cols’, ‘clear_cache’, ‘classes’]
329 txt_kwargs, kwargs = extract_kwargs(k_names, kwargs)
–> 330 train_ds = TextDataset.from_df(path, train_df, tokenizer, ‘train’, vocab=vocab, **txt_kwargs)
331 datasets = [train_ds, TextDataset.from_df(path, valid_df, tokenizer, ‘valid’, vocab=train_ds.vocab, **txt_kwargs)]
332 if test_df is not None: datasets.append(TextDataset.from_df(path, test_df, tokenizer, ‘test’, vocab=train_ds.vocab, **txt_kwargs))

~\AppData\Roaming\Python\Python36\site-packages\fastai\text\data.py in from_df(cls, folder, df, tokenizer, name, **kwargs)
151 tokenizer = ifnone(tokenizer, Tokenizer())
152 chunksize = 1 if (type(df) == DataFrame) else df.chunksize
–> 153 return cls(folder, tokenizer, df=df, create_mtd=TextMtd.DF, name=name, chunksize=chunksize, **kwargs)
154
155 @classmethod

~\AppData\Roaming\Python\Python36\site-packages\fastai\text\data.py in init(self, path, tokenizer, vocab, max_vocab, chunksize, name, df, min_freq, n_labels, txt_cols, label_cols, create_mtd, classes, clear_cache)
35 os.makedirs(self.path, exist_ok=True)
36 if clear_cache: self.clear()
—> 37 if not self.check_toks(): self.tokenize()
38 if not self.check_ids(): self.numericalize()
39

~\AppData\Roaming\Python\Python36\site-packages\fastai\text\data.py in tokenize(self)
89 lbls = df[self.label_cols].values.astype(lbl_type) if (len(self.label_cols) > 0) else []
90 self.txt_cols = ifnone(self.txt_cols, list(range(len(self.label_cols),len(df.columns))))
—> 91 texts = f’{FLD} {1} ’ + df[self.txt_cols[0]].astype(str)
92 for i, col in enumerate(self.txt_cols[1:]): texts += f’ {FLD} {i+2} ’ + df[col].astype(str)
93 toks = self.tokenizer.process_all(texts)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\frame.py in getitem(self, key)
2683 return self._getitem_multilevel(key)
2684 else:
-> 2685 return self._getitem_column(key)
2686
2687 def _getitem_column(self, key):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\frame.py in _getitem_column(self, key)
2690 # get column
2691 if self.columns.is_unique:
-> 2692 return self._get_item_cache(key)
2693
2694 # duplicate columns & possible reduce dimensionality

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py in _get_item_cache(self, item)
2484 res = cache.get(item)
2485 if res is None:
-> 2486 values = self._data.get(item)
2487 res = self._box_item_values(item, values)
2488 cache[item] = res

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\internals.py in get(self, item, fastpath)
4113
4114 if not isna(item):
-> 4115 loc = self.items.get_loc(item)
4116 else:
4117 indexer = np.arange(len(self.items))[isna(self.items)]

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3063 return self._engine.get_loc(key)
3064 except KeyError:
-> 3065 return self._engine.get_loc(self._maybe_cast_indexer(key))
3066
3067 indexer = self.get_indexer([key], method=method, tolerance=tolerance)

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: 1