-
-
Notifications
You must be signed in to change notification settings - Fork 329
Open
Description
It'd be nice to have the ability to convert datetime columns to ordinal values. The DatetimeFeatures is nice for when one wants to extract the year, month, day, etc., but sometimes it's desirable to have the date simply as an ordinal value.
Here's an example I've used in code before:
class DatetimeOrdinal(BaseEstimator, TransformerMixin):
def fit(self, X, y=None):
return self
def transform(self, X):
return X.apply(lambda x: x.map(pd.Timestamp.toordinal, na_action='ignore'))
def inverse_transform(self, X):
return X.apply(lambda x: x.map(pd.Timestamp.fromordinal, na_action='ignore'))
Metadata
Metadata
Assignees
Labels
No labels