hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

Interactive: using `.pipe`/`.apply` in a pipeline triggers the piped/applied function too many times

Open maximlt opened this issue 3 years ago • 0 comments

Using the Pandas .pipe method to transform a DataFrame in a pipeline triggers the piped function more times than it should, as demonstrated by the example below:

import hvplot.pandas
import pandas as pd

df = pd.DataFrame()

def transform_data(df, transform):
    print(f"Transforming {transform}")
    return df


print("-------------")
print('Interactive init')

pipeline = df.interactive()

print("-------------")
print('Pipe Step 1:')

pipeline = pipeline.pipe(transform_data, transform="Step 1")

print("-------------")
print('Pipe Step 2:')

pipeline = pipeline.pipe(transform_data, transform="Step 2")

print("-------------")
print('Pipe Step 3:')

pipeline = pipeline.pipe(transform_data, transform="Step 3")
-------------
Interactive init
-------------
Pipe Step 1
Transforming Step 1
-------------
Pipe Step 2
Transforming Step 1
Transforming Step 1
Transforming Step 1
Transforming Step 2
-------------
Pipe Step 3
Transforming Step 1
Transforming Step 2
Transforming Step 1
Transforming Step 2
Transforming Step 1
Transforming Step 2
Transforming Step 3

maximlt avatar Aug 12 '22 09:08 maximlt