Help required with below issue!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssachin06
    New Member
    • Aug 2019
    • 1

    Help required with below issue!

    Trying to perform rfm on my database. In order to calculate number of days using below code -
    Code:
    sd = dt.date(2019, 8, 1)
    data['hist']=sd - data['transaction_created']
    data['hist'].astype('timedelta64[D]')
    data['hist']=data['hist'] / np.timedelta64(1, 'D')
    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_cre ated

    But getting following error upon execution - "TypeError: descriptor 'date' requires a 'datetime.datet ime' object but received a 'int' "
    Could anyone help me out with this? Would highly appreciate it.
    Last edited by gits; Aug 21 '19, 07:32 AM. Reason: please use code tags
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    But getting following error upon execution - "TypeError: descriptor 'date' requires a 'datetime.datet ime' object but received a 'int' "
    Self explanatory. You can subtract two ints or two datetime objects but not one of each. Use type(variable_n ame) to see which is which.

    Comment

    Working...