Skip to content

Commit

Permalink
use default date parsing lol
Browse files Browse the repository at this point in the history
  • Loading branch information
cthorrez committed Oct 31, 2024
1 parent 51f4ed8 commit 6c8bd53
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions riix/utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ def __init__(
elif df.schema[datetime_col] == pl.Date:
datetime = df[datetime_col].cast(pl.Datetime)
elif df.schema[datetime_col] == pl.Utf8:
datetime = df.with_columns(
pl.when(pl.col(datetime_col).str.contains(r'^\d{4}-\d{2}-\d{2}$')) # Match 'yyyy-mm-dd'
.then(pl.col(datetime_col).str.to_date('%Y-%m-%d'))
.otherwise(pl.col(datetime_col).str.strptime(pl.Datetime, '%Y-%m-%dT%H:%M:%S%.f', strict=False))
)[datetime_col]
datetime = df[datetime_col].str.to_datetime()
else:
raise ValueError('datetime_col must be one of Date, Datetime, or Utf8')
seconds_since_epoch = (datetime.dt.timestamp() // 1_000_000).to_numpy()
Expand Down

0 comments on commit 6c8bd53

Please sign in to comment.