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

Initial Polars support #1576

Open
wants to merge 41 commits into
base: mainline
Choose a base branch
from
Open

Initial Polars support #1576

wants to merge 41 commits into from

Conversation

richard-rogers
Copy link
Contributor

@richard-rogers richard-rogers commented Oct 18, 2024

Description

Support for logging Polars data frames.

Closes #1230

@richard-rogers richard-rogers marked this pull request as draft October 18, 2024 04:41


def test_validator_double_register_udf_polars() -> None:
global action_list
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can drop this test.

Comment on lines +60 to +61
d = {g: grouped.get_group(g) for g in grouped.groups.keys()}
return d
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
d = {g: grouped.get_group(g) for g in grouped.groups.keys()}
return d

if not isinstance(dtype_or_type, type):
return False

if issubclass(dtype_or_type, (bool, int, np.number, np.bool_)):
if issubclass(dtype_or_type, (bool, int, np.number, np.bool_, pl.datatypes.IntegerType)):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if issubclass(dtype_or_type, (bool, int, np.number, np.bool_, pl.datatypes.IntegerType)):
if issubclass(dtype_or_type, (bool, int, np.number, np.bool_)):

SplitSeries with multiple values, including numpy arrays for numbers, and strings as a Polars Series.
"""

# TODO: add a PolarsView, or convert PandasView to work with both Polars & Pandas
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should extract a View base class and make ListView, NumpyView, PandasView, PolarsView <: View. PolarsView might be better than NumpyView for ints and floats. PreprocessedColumn would contain a list of View instances rather than members of each specific View subclass.

except Exception as e: # noqa
new_df[new_col] = pd.Series([None])
new_df[new_col] = df.apply_udf(lambda x: float("nan")) # should be None, but can't infer type
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be better to just leave out the failed UDF's output column.

@richard-rogers richard-rogers marked this pull request as ready for review November 12, 2024 22:54
exclude: python/whylogs/core/proto/|python/docs/|python/whylogs/viz/html/|java|python/whylogs/api/logger/experimental/logger
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
hooks:
- id: mypy
language: system
exclude: ^(python/tests/|python/examples/|python/examples/integration/|python/whylogs/core/proto/|python/docs/|python/whylogs/viz/html/|java|python/whylogs/api/logger/experimental/logger)
files: ^(python/whylogs/)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not positive this check the correct files, but this was the only way I found to get it to not run lint checks on site-packages.

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.

Support polars
1 participant