Proc_df fails on datetime64[ns] datatype

I’m running proc_df on the googleanalytics kaggle data. I had previously run this command:

train[‘visitStartTime’] = pd.to_datetime(train.visitStartTime, unit=‘s’) #check back on dates
test[‘visitStartTime’] = pd.to_datetime(test.visitStartTime, unit=‘s’)

the line “if not is_numeric_dtype(col)” does not realize a colum with datetime64[ns] data is not categorical


AttributeError Traceback (most recent call last)
in
----> 1 proc_df(train, ‘totals.transactionRevenue’)

~/Desktop/Kaggle/GoogleAnalytics/fastai/structured.py in proc_df(df, y_fld, skip_flds, ignore_flds, do_scale, na_dict, preproc_fn, max_n_cat, subset, mapper)
444 df.drop([a + ‘_na’ for a in list(set(na_dict.keys()) - set(na_dict_initial.keys()))], axis=1, inplace=True)
445 if do_scale: mapper = scale_vars(df, mapper)
–> 446 for n,c in df.items(): numericalize(df, c, n, max_n_cat)
447 df = pd.get_dummies(df, dummy_na=True)
448 df = pd.concat([ignored_flds, df], axis=1)

~/Desktop/Kaggle/GoogleAnalytics/fastai/structured.py in numericalize(df, col, name, max_n_cat)
321 “”"
322 if not is_numeric_dtype(col) and ( max_n_cat is None or len(col.cat.categories)>max_n_cat):
–> 323 df[name] = col.cat.codes+1
324
325 def scale_vars(df, mapper):

/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py in getattr(self, name)
4370 if (name in self._internal_names_set or name in self._metadata or
4371 name in self._accessors):
-> 4372 return object.getattribute(self, name)
4373 else:
4374 if self._info_axis._can_hold_identifiers_and_holds_name(name):

/anaconda3/lib/python3.6/site-packages/pandas/core/accessor.py in get(self, obj, cls)
131 # we’re accessing the attribute of the class, i.e., Dataset.geo
132 return self._accessor
–> 133 accessor_obj = self._accessor(obj)
134 # Replace the property with the accessor object. Inspired by:
135 # http://www.pydanny.com/cached-property.html

/anaconda3/lib/python3.6/site-packages/pandas/core/arrays/categorical.py in init(self, data)
2375
2376 def init(self, data):
-> 2377 self._validate(data)
2378 self.categorical = data.values
2379 self.index = data.index

/anaconda3/lib/python3.6/site-packages/pandas/core/arrays/categorical.py in _validate(data)
2384 def _validate(data):
2385 if not is_categorical_dtype(data.dtype):
-> 2386 raise AttributeError("Can only use .cat accessor with a "
2387 “‘category’ dtype”)
2388

AttributeError: Can only use .cat accessor with a ‘category’ dtype