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

Error on printing rx #939

Open
ahuang11 opened this issue May 14, 2024 · 0 comments
Open

Error on printing rx #939

ahuang11 opened this issue May 14, 2024 · 0 comments
Labels
type-bug Bug report

Comments

@ahuang11
Copy link
Contributor

Trying to figure out what's an rx object and not by printing, but it ends up raising an error.

from io import BytesIO
import pandas as pd
import panel as pn
pn.extension()

@pn.cache
def get_stocks(data):
    if data is None:
        stock_file = 'https://datasets.holoviz.org/stocks/v1/stocks.csv'
    else:
        stock_file = BytesIO(data)
    return pd.read_csv(stock_file, index_col='Date', parse_dates=True)


file_input = pn.widgets.FileInput(sizing_mode='stretch_width')

stocks = pn.rx(get_stocks)(file_input)

selector = pn.widgets.MultiSelect(
    name='Select stocks', sizing_mode='stretch_width',
    options=stocks.columns.to_list()
)

selected_stocks = stocks.rx.pipe(
    lambda df, cols: df[cols] if cols else df, selector
)

print(selected_stocks)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[3], line 28
     19 selector = pn.widgets.MultiSelect(
     20     name='Select stocks', sizing_mode='stretch_width',
     21     options=stocks.columns.to_list()
     22 )
     24 selected_stocks = stocks.rx.pipe(
     25     lambda df, cols: df[cols] if cols else df, selector
     26 )
---> 28 print(selected_stocks)

TypeError: __str__ returned non-string (type rx)
@ahuang11 ahuang11 added type-bug Bug report TRIAGE User-submitted issue that hasn't been triaged yet. labels May 14, 2024
@ahuang11 ahuang11 removed the TRIAGE User-submitted issue that hasn't been triaged yet. label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Bug report
Projects
None yet
Development

No branches or pull requests

1 participant