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

Add additional generic types to DataFrame methods #302

Merged
merged 5 commits into from
Dec 17, 2024

Conversation

controversial
Copy link
Contributor

@controversial controversial commented Dec 9, 2024

Adding generic types to a few more methods beyond what was added in #293 by @scarf005

Focusing mostly on adding identity types to methods which I believe don’t change the original type of the dataframe. I added “identity” type signatures to the following methods:

extend, fillNull, filter, interpolate, limit, max, mean, median, min, quantile, rechunk, shiftAndFill, shrinkToFit, slice, sort, std, sum, tail, unique, var, vstack, where, upsample

These previously returned DataFrame<any>, even when called on a well-typed DataFrame, but now return DataFrame<T> (the original type)


I also added better types for a few slightly more complex ones:

  • map
    • improved return type based on the function passed, but unimproved parameter type
  • nullCount
  • toRecords
  • toSeries
    • for now, returning a broad union type, rather than identifying the specific column by index
  • withColumn

Along the way, I added minor fixes for the types of:

  1. pl.intRange [1] which had overloads in the wrong order leading to incorrect return types, and
  2. the pl.Series(name, values, dtype) constructor [2], whose strongly-typed overload was failing to apply in simple cases like pl.Series("index", [0, 1, 2, 3, 4], pl.Int64) when the input array used numbers instead of BigInts

@controversial
Copy link
Contributor Author

will work on test failures

@controversial controversial marked this pull request as draft December 9, 2024 22:20
@controversial controversial marked this pull request as ready for review December 9, 2024 23:37
@controversial
Copy link
Contributor Author

Have now addressed the previous test failures

@universalmind303 universalmind303 merged commit 8816b46 into pola-rs:main Dec 17, 2024
12 checks passed
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