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

Feature/nw datediffleapyeartransformer #394

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

ChristinaKatsiafa
Copy link
Contributor

This is a pull request to convert datediffleapyeartransformer to narwhals.

@ChristinaKatsiafa ChristinaKatsiafa linked an issue Mar 18, 2025 that may be closed by this pull request
Copy link
Contributor

@davidhopkinson26 davidhopkinson26 left a comment

Choose a reason for hiding this comment

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

thanks for this @ChristinaKatsiafa. Think there is still a bit to do, as I think you need to also narwhalify calculate_age so we can remove the pandas specific logic in transform.

tubular/dates.py Outdated

X[self.new_column_name] = X.apply(self.calculate_age, axis=1)
X = X.to_native()
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: not sure I get why we are doing this last step, what dtype is coming out of the above operation? Understand we were getting issues with the dtype in the expected dataframes for tests when nulls present but did not realise we were also casting here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because narwhals returns the results as int64[pyarrow] instead of Int64. So I just force the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure returning int64[pyarrow] is a problem so would be inclined to leave it and update the test rather than here. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change is ready to review :)

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.

narwhalify DateDifferenceTransformer
2 participants