Python Forum
How to subtract columns with dates?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to subtract columns with dates?
#1
Hi everyone, I have the code below that first creates a column with today's date (works) then I subtract an existing column but I get a TypeError. I ran the Dtype function and found that the excl.test column is being returned as an object (string), how can I convert this field into a date? Note, the excl.Date column is formatted as a date yyy-mm-dd.

from datetime import date

excl['test'] = (today)
print(excl.test - excl.Date)
Reply


Messages In This Thread
How to subtract columns with dates? - by jpy - Dec-28-2020, 08:35 PM
RE: How to subtract columns with dates? - by jpy - Dec-28-2020, 10:13 PM
RE: How to subtract columns with dates? - by jpy - Dec-29-2020, 12:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fastest way to subtract elements of datasets of HDF5 file? Robotguy 3 2,884 Aug-01-2020, 11:48 PM
Last Post: scidam
  Groupby in pandas with conditional - add and subtract rregorr 2 7,114 Jul-12-2019, 05:17 PM
Last Post: rregorr
  Subtract rows (like r[1]-r[2] and r[3]-r[3]) and no pandas pradeepkumarbe 1 2,698 Dec-18-2018, 01:16 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020