0

This code enables to convert previous types to date:

import datetime
from datetime import date, datetime
date1 = pd.to_datetime(payments['ts'])
date2 = pd.to_datetime(payments['date'])

the next step is adding a new column. In order to easily manipulate it, I think, I need to leave days alone since if I simply write:

payments['delta'] = date1 - date2

I get a complete date like 10 days 04:04:06.608152. Thus if I wish to filter out by SQL WHERE condition, or a pandas payments[payments['delta'] > TBD] condition, where the sought condition is simply some integer of days, this doesn't work, namely I get an empty dataframe as no instance satisfies the condition. Thus, I deem, I need to trim the date simply to days. If my logick is false and ye were kind to advise me a more rational one, I would owe ye greatly. Thank ye.

Versteher
  • 23
  • 5
  • 2
    Add sample input and sample output – ggaurav Dec 24 '20 at 14:25
  • Does this answer your question? [Add column with number of days between dates in DataFrame pandas](https://stackoverflow.com/questions/22132525/add-column-with-number-of-days-between-dates-in-dataframe-pandas) – Rajat Mishra Dec 24 '20 at 14:26
  • that example used indeces, thus did not have restrictions of Series. My example needs to operate on Series, namely columns – Versteher Dec 24 '20 at 15:11

0 Answers0