ln [48 ]: set_entrainement = basket_price[basket_price['InvoiceDate'] < datetime.date(2011,10,1)]
set_test = basket_price[basket_price['InvoiceDate'] >= datetime.date(2011,10,1)]
basket_price = set_entrainement.copy(deep = True)
TypeError Traceback (most recent call last)
in ()
----> 1 set_entrainement = basket_price[basket_price['InvoiceDate'] < datetime.date(2011,10,1)]
2 set_test = basket_price[basket_price['InvoiceDate'] >= datetime.date(2011,10,1)]
3 basket_price = set_entrainement.copy(deep = True)
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pandas\core\ops.py in wrapper(self, other, axis)
1199 # Series/Index behavior
1200 res_values = dispatch_to_index_op(op, self, other,
-> 1201 pd.DatetimeIndex)
1202 return self._constructor(res_values, index=self.index,
1203 name=res_name)
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pandas\core\ops.py in dispatch_to_index_op(op, left, right, index_class)
1096 left_idx = left_idx._shallow_copy(freq=None)
1097 try:
-> 1098 result = op(left_idx, right)
1099 except NullFrequencyError:
1100 # DatetimeIndex and TimedeltaIndex with freq == None raise ValueError
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pandas\core\indexes\datetimes.py in wrapper(self, other)
131 return np.ones(shape=self.shape, dtype=bool)
132 raise TypeError('%s type object %s' %
--> 133 (type(other), str(other)))
134
135 if is_datetimelike(other):
TypeError: <class 'datetime.date'> type object 2011-10-01
from datetime import date
from datetime import datetime
and removed 'date' from datetime.date as below and it worked
set_entrainement = basket_price[basket_price['InvoiceDate'] < datetime(2011,10,1)]
set_test = basket_price[basket_price['InvoiceDate'] >= datetime(2011,10,1)]
basket_price = set_entrainement.copy(deep = True)