0

I am using this function from How to convert a given ordinal number (from Excel) to a date

from datetime import datetime, timedelta

def from_excel_ordinal(ordinal, _epoch0=datetime(1899, 12, 31)):
    if ordinal >= 60:
        ordinal -= 1  # Excel leap year bug, 1900 is not a leap year!
    return (_epoch0 + timedelta(days=ordinal)).replace(microsecond=0)
from_excel_ordinal(44192.0)
**OUTPUT = datetime.datetime(2020, 12, 27, 0, 0) ** Which is corrrect

However, when I try to apply the function to the $Date column:

Delivery_Data['Date'] = Delivery_Data['Date'].apply(from_excel_ordinal)

I receive an Output = '>=' not supported between instances of 'Timestamp' and 'int'. I tried this link: Pandas: TypeError: '>' not supported between instances of 'int' and 'str' when selecting on date column but it didn't work.

0 Answers0