Skip to content
Advertisement

how can get difference between a defined date and the dates from a csv file python

I have a list of dates and I want to get a difference from a defined one(I mean days) and append days calculated in a new column

JavaScript

I get TypeError: unsupported operand type(s) for -: 'DatetimeArray' and 'datetime.date'

Now how can I read the dates in csv file in the same format as the defined date is there a way to do so

JavaScript

Advertisement

Answer

It is happening because you are trying to subtract array(series) from defined_date. Which doesn’t work like that. You need to iterate over your csv_dates series and add differences to the new column.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement