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

PD.DataFrame is not supported for State #279

Closed
qu3vipon opened this issue Jan 18, 2023 · 8 comments · Fixed by #324 or #396
Closed

PD.DataFrame is not supported for State #279

qu3vipon opened this issue Jan 18, 2023 · 8 comments · Fixed by #324 or #396
Assignees
Labels
bug Something isn't working
Milestone

Comments

@qu3vipon
Copy link
Contributor

Describe the bug
pd.DataFrame type is not supported for State

To Reproduce

class State(pc.State):
   data: pd.DataFrame

Error Message

$ TypeError: State vars must be primitive Python types, Plotly figures, Pandas dataframes, or subclasses of pc.Base. Found var “data” with type <class ‘pandas.core.frame.DataFrame’>.

Code

  • couldn’t find pd.DataFrame in Valid state var types
# pynecone/utils.py L60

# Valid state var types
PrimitiveType = Union[int, float, bool, str, list, dict, tuple]
StateVar = Union[PrimitiveType, Base, None]

Specifics (please complete the following information):

  • Python Version: 3.8.10
  • Pynecone Version: 0.1.12
  • OS: mac OS
@Alek99
Copy link
Member

Alek99 commented Jan 19, 2023

Looking into this now

@Alek99 Alek99 self-assigned this Jan 19, 2023
@Alek99 Alek99 added the bug Something isn't working label Jan 19, 2023
@Alek99
Copy link
Member

Alek99 commented Jan 19, 2023

This is a bug on our side will be fixing asap

@Alek99
Copy link
Member

Alek99 commented Jan 19, 2023

In the mean time it seems computed vars for pandas is working see this example, https://github.com/pynecone-io/pynecone-examples/blob/main/nba/nba/nba.py

@Alek99 Alek99 added this to the v0.1.14 milestone Jan 19, 2023
@wongni
Copy link

wongni commented Jan 22, 2023

In the mean time it seems computed vars for pandas is working see this example, https://github.com/pynecone-io/pynecone-examples/blob/main/nba/nba/nba.py

@Alek99 When I used the computed var in the data_table's data prop I am getting this error. Is this also a bug?

            pc.data_table(
                data=State.df,
                pagination=True,
                search=True,
                sort=True,
                resizable=True,
            ),

image

@Alek99
Copy link
Member

Alek99 commented Jan 22, 2023

Hmm just ran the example and it seems to be working for me what pynecone version are you on and did you change the code at all

@wongni
Copy link

wongni commented Jan 23, 2023

Hmm just ran the example and it seems to be working for me what pynecone version are you on and did you change the code at all

I am using pynecone 0.1.13 version and python 3.9.13 version. And the only code I changed in the nba example's main branch was from data=nba_data, to data=State.df,. I tried both Firefox and Chrome browsers on Mac but still got An error happened while fetching the data error on the table.

@picklelo picklelo assigned picklelo and unassigned Alek99 Jan 24, 2023
@picklelo
Copy link
Contributor

@wongni I'm seeing this too - working on a fix now.

@picklelo picklelo linked a pull request Jan 24, 2023 that will close this issue
@Alek99 Alek99 linked a pull request Jan 30, 2023 that will close this issue
11 tasks
@rohitsathish
Copy link

What's the right way to instantiate a pandas dataframe in rx.State? Still seem to be getting errors with this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants