473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Help required with below issue!

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.
Aug 20 '19 #1
1 1210
dwblas
626 Expert 512MB
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.
Aug 20 '19 #2

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

Similar topics

0
by: Ryan Schefke | last post by:
------=_NextPart_000_0077_01C34C8B.2B90C960 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ..I just sent this out to the win32 distribution list but no one has...
1
by: stuart dent via .NET 247 | last post by:
XML validation error. Help required If anyone can help me, thankyou, thankyou... When I run this code code I get this error: The data at the root level is invalid. Line 1, position 39. I...
3
by: RWC | last post by:
Hello, I have an issue that's driving me batty! I have a report, whose record source is SQL based on a normalized set of tables. There are no nested queries and no dlookups in this record...
0
by: JonathanParker | last post by:
Hello, Wondered if you could help me with a little issue I'm having. I'm exporting some data from Access to Excel and converting into some fancy graphs. The number of series' ranges from 2 to 5....
18
by: Blackspeech | last post by:
We have Siebel running in a test environment and experiencing problems as described below: We receive automated trouble ticket information from a Remedy based system that emails Siebel and...
3
by: madhumita.iyengar | last post by:
Hi all I am creating a web services application in Visual Studio Dot net which links to a MS SQL database. I need to create a form which lets the user pick his field of choice(doesnt matter...
5
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
9
by: lombardm | last post by:
I am trying to decipher/translate some code that I have no experience with. I am trying to find out how the checksum is computed for a Megellan Explorist GPS Waypoint (POI) file. Below is the...
5
by: dannynnad | last post by:
Hi, SuperAdministrator when trying to edit the frontend content the following error is comingup: "You are not authorized to view this resource." I checked from the backend whether the...
2
by: NIKHILUNNIKRISHNAN | last post by:
Hi, My name is Nikhil. I am new to programming.I am obfuscating a C# solution using Dotfuscator. The output of the soultion is a UI along with a setup to install the application. The setup is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.