Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored DateTimeTransformer to use narwhals #382

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

favouribude1
Copy link
Contributor

Currently havin one test failing.
image

**self.to_datetime_kwargs,
)
native_X = X.to_native()
if isinstance(native_X, pd.DataFrame):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

narwhals is designed to avoid having to implement branching polars/pandas handling like this, the idea is to make use of narwhals methods, which will translate between pandas/polars behind the scenes. In this case, would try something like

time_unit=self.to_datetime_kwargs.get('time_unit', None)
time_zone=self.to_datetime_kwargs.get('time_zone', None)
df=df.with_columns(nw.col(columns[0]).cast(nw.Datetime(time_unit=time_unit, time_zone=time_zone)))

@davidhopkinson26 davidhopkinson26 changed the title Refactored code to use narwhal Refactored DateTimeTransformer to use narwhals Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants