I run the notebook (lesson3-imdb) from Jeremy with this code:
data_lm = (TextList.from_folder(path) #Inputs: all the text files in path .filter_by_folder(include=['train', 'test']) #We may have other temp folders that contain text files so we only keep what's in train and test .random_split_by_pct(0.1) #We randomly split and keep 10% (10,000 reviews) for validation .label_for_lm() #We want to do a language model so we label accordingly .databunch(bs=bs)) data_lm.save('tmp_lm')
And than I get this:
TypeError Traceback (most recent call last)
/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in na_op(x, y)
1011 try:
-> 1012 result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)
1013 except TypeError:/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/computation/expressions.py in evaluate(op, op_str, a, b, use_numexpr, **eval_kwargs)
204 if use_numexpr:
–> 205 return _evaluate(op, op_str, a, b, **eval_kwargs)
206 return _evaluate_standard(op, op_str, a, b)/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/computation/expressions.py in _evaluate_numexpr(op, op_str, a, b, truediv, reversed, **eval_kwargs)
119 if result is None:
–> 120 result = _evaluate_standard(op, op_str, a, b)
121/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/computation/expressions.py in _evaluate_standard(op, op_str, a, b, **eval_kwargs)
64 with np.errstate(all=‘ignore’):
—> 65 return op(a, b)
66/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in radd(left, right)
112 def radd(left, right):
–> 113 return right + left
114TypeError: must be str, not PosixPath
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in safe_na_op(lvalues, rvalues)
1032 with np.errstate(all=‘ignore’):
-> 1033 return na_op(lvalues, rvalues)
1034 except Exception:/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in na_op(x, y)
1022 mask = notna(x)
-> 1023 result[mask] = op(x[mask], y)
1024/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in radd(left, right)
112 def radd(left, right):
–> 113 return right + left
114TypeError: must be str, not PosixPath
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
in
3 .filter_by_folder(include=[‘train’, ‘test’])
4 #We may have other temp folders that contain text files so we only keep what’s in train and test
----> 5 .random_split_by_pct(0.1)
6 #We randomly split and keep 10% (10,000 reviews) for validation
7 .label_for_lm()/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py in _inner(*args, **kwargs)
260 self.valid = fv(*args, template=self.train.y, **kwargs)
261 self.class = LabelLists
–> 262 self.process()
263 return self
264 return _inner/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py in process(self)
301 def process(self):
302 xp,yp = self.get_processors()
–> 303 for ds in self.lists: ds.process(xp, yp)
304 return self
305/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py in process(self, xp, yp)
363 def process(self, xp=None, yp=None):
364 “Launch the preprocessing onxp
andyp
.”
–> 365 self.x.process(xp)
366 self.y.process(yp)
367 return self/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py in process(self, processor)
59 if processor is not None: self.processor = processor
60 if not is_listy(self.processor): self.processor = [self.processor]
—> 61 for p in self.processor: p.process(self)
62 return self
63/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/text/data.py in process(self, ds)
296 def process_one(self, item): return self.tokenizer._process_all_1([item])[0]
297 def process(self, ds):
–> 298 ds.items = _join_texts(ds.items, self.mark_fields)
299 tokens = []
300 for i in progress_bar(range(0,len(ds),self.chunksize), leave=False):/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/text/data.py in _join_texts(texts, mark_fields)
285 if is1d(texts): texts = texts[:,None]
286 df = pd.DataFrame({i:texts[:,i] for i in range(texts.shape[1])})
–> 287 text_col = f’{FLD} {1} ’ + df[0] if mark_fields else df[txt_cols[0]]
288 for i in range(1,len(df.columns)):
289 text_col += (f’ {FLD} {i+1} ’ if mark_fields else ’ ') + df[i]/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in wrapper(left, right)
1067 rvalues = rvalues.values
1068
-> 1069 result = safe_na_op(lvalues, rvalues)
1070 return construct_result(left, result,
1071 index=left.index, name=res_name, dtype=None)/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in safe_na_op(lvalues, rvalues)
1035 if is_object_dtype(lvalues):
1036 return libalgos.arrmap_object(lvalues,
-> 1037 lambda x: op(x, rvalues))
1038 raise
1039pandas/_libs/algos_common_helper.pxi in pandas._libs.algos.arrmap_object()
/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in (x)
1035 if is_object_dtype(lvalues):
1036 return libalgos.arrmap_object(lvalues,
-> 1037 lambda x: op(x, rvalues))
1038 raise
1039/opt/conda/envs/fastai/lib/python3.6/site-packages/pandas/core/ops.py in radd(left, right)
111
112 def radd(left, right):
–> 113 return right + left
114
115TypeError: must be str, not PosixPath
Can someone help me, cause I really don’t know hoe to solve this.
I know the path comes as an PosixPath, but when I make it a string the error is still there.