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

SNOW-1897976: Consider adding a new DataFrame method to allow applying transformations in the fluent-style #2939

Open
padhia opened this issue Jan 25, 2025 · 0 comments
Labels
feature New feature or request

Comments

@padhia
Copy link

padhia commented Jan 25, 2025

What is the current behavior?

Currently, to apply transformations to a dataframe, one needs to create a named variable to call a transformation function.

E.g. consider transformation functions such as

def dedup(df: DataFrame) -> DataFrame:
    ...

def add_audit_cols(df: DataFrame) -> DataFrame:
    ...

my_df: DataFrame = ...

t1 = dedeup(my_df)
transformed_df = add_audit_cols(t1)

What is the desired behavior?

Defined a new method that allows fluent style coding

class DataFrame:
   # This is a proposed method to allow fluent-style API
    def pipe(self, f: Callable[[DataFrame], DataFrame]) -> DataFrame:
        return f(self)

# revised code

transformed_df = my_df.pipe(dedup).pipe(add_audit_cols) 

How would this improve snowflake-snowpark-python?

Fluent-style code feels more ergonomic and matches the style of most built-in DataFrame methods

References, Other Background

@padhia padhia added the feature New feature or request label Jan 25, 2025
@github-actions github-actions bot changed the title Consider adding a new DataFrame method to allow applying transformations in the fluent-style SNOW-1897976: Consider adding a new DataFrame method to allow applying transformations in the fluent-style Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant