By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,816 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,816 IT Pros & Developers. It's quick & easy.

Help required with below issue!

P: 1
Trying to perform rfm on my database. In order to calculate number of days using below code -
Expand|Select|Wrap|Line Numbers
  1. sd = dt.date(2019, 8, 1)
  2. data['hist']=sd - data['transaction_created']
  3. data['hist'].astype('timedelta64[D]')
  4. data['hist']=data['hist'] / np.timedelta64(1, 'D')
  5. data.head()
Have converted my dates into date form while importing data to python using below SQL query -
to_char (r.created_at, 'yyyy-mm-dd') user_created,
to_char (t.created_at, 'yyyy-mm-dd') transaction_created

But getting following error upon execution - "TypeError: descriptor 'date' requires a 'datetime.datetime' object but received a 'int' "
Could anyone help me out with this? Would highly appreciate it.
3 Weeks Ago #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 619
But getting following error upon execution - "TypeError: descriptor 'date' requires a 'datetime.datetime' object but received a 'int' "
Self explanatory. You can subtract two ints or two datetime objects but not one of each. Use type(variable_name) to see which is which.
3 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.