Issue Running Lesson 3

Hi,

Anyone face the current issue AttributeError: Can only use .dt accessor with datetimelike values ?
Seem like having issue with pandas, did try to solve this by

weather[‘Date’] = pd.to_datetime(weather[‘Date’], format = ‘%Y-%b-%d’)

But that generate another problem later in the code.

TypeError Traceback (most recent call last) ~/.conda/envs/tf-gpu/lib/python3.6/site-packages/pandas/core/series.py in _make_dt_accessor(self) 2819 try: -> 2820 return maybe_to_datetimelike(self) 2821 except Exception:

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/pandas/core/indexes/accessors.py in maybe_to_datetimelike(data, copy)
83 raise TypeError("cannot convert an object of type {0} to a "
—> 84 “datetimelike index”.format(type(data)))
85

TypeError: cannot convert an object of type <class ‘pandas.core.series.Series’> to a datetimelike index

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
in ()
----> 1 add_datepart(weather, “Date”)
2 add_datepart(googletrend, “Date”)
3 add_datepart(train, “Date”)
4 add_datepart(test, “Date”)

/opt/project/fastai/courses/dl1/fastai/structured.py in add_datepart(df, fldname, drop)
107 for n in (‘Year’, ‘Month’, ‘Week’, ‘Day’, ‘Dayofweek’, ‘Dayofyear’,
108 ‘Is_month_end’, ‘Is_month_start’, ‘Is_quarter_end’, ‘Is_quarter_start’, ‘Is_year_end’, ‘Is_year_start’):
–> 109 df[targ_pre+n] = getattr(fld.dt,n.lower())
110 df[targ_pre+‘Elapsed’] = fld.astype(np.int64) // 10**9
111 if drop: df.drop(fldname, axis=1, inplace=True)

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/pandas/core/generic.py in getattr(self, name)
3075 if (name in self._internal_names_set or name in self._metadata or
3076 name in self._accessors):
-> 3077 return object.getattribute(self, name)
3078 else:
3079 if name in self._info_axis:

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/pandas/core/base.py in get(self, instance, owner)
241 # this ensures that Series.str. is well defined
242 return self.accessor_cls
–> 243 return self.construct_accessor(instance)
244
245 def set(self, instance, value):

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/pandas/core/series.py in _make_dt_accessor(self)
2820 return maybe_to_datetimelike(self)
2821 except Exception:
-> 2822 raise AttributeError("Can only use .dt accessor with datetimelike "
2823 “values”)
2824

AttributeError: Can only use .dt accessor with datetimelike values

Thanks for letting us know. That’s fixed now - do a git pull and try again. I ran through all the preprocessing steps and training from the top and it worked for me.

Thanks @jeremy manage to get it almost running now, quick question about RandomForestRegressor (RF) part do ?

Hit an error at that part, NameError: name ‘exp_rmspe’ is not defined

NameError Traceback (most recent call last) in () 1 preds = m.predict(val) ----> 2 m.score(trn, y_trn), m.score(val, y_val), m.oob_score_, exp_rmspe(preds, y_val)

NameError: name ‘exp_rmspe’ is not defined

Best to skip over the RF part - it’s not related to this course at all.