Skip to content

Commit

Permalink
Fix to_datetime function
Browse files Browse the repository at this point in the history
  • Loading branch information
luis11011 committed Sep 3, 2021
1 parent 8b3aec6 commit e71442b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions optimus/engines/base/pandas/functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

from optimus.helpers.logger import logger
import numpy as np
import pandas as pd
from fastnumbers import isintlike, isfloat, isreal, fast_forceint, fast_float
Expand Down Expand Up @@ -80,10 +81,12 @@ def _to_float(cls, series):

@classmethod
def _to_datetime(cls, value, format=None):
if format is None:
return cls._partition_engine.to_datetime(value, errors="coerce")
else:
return cls._partition_engine.to_datetime(value, format=format, errors="coerce")
try:
if format is not None:
return cls._partition_engine.to_datetime(value, format=format, errors="coerce")
except Exception as e:
logger.warn(e)
return cls._partition_engine.to_datetime(value, errors="coerce")

@classmethod
def format_date(cls, series, current_format=None, output_format=None):
Expand Down

0 comments on commit e71442b

Please sign in to comment.