-
Notifications
You must be signed in to change notification settings - Fork 263
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
improvement: auto-encoding pandas/numpy, mo.ui.table takes in Dataframe #197
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
marimo/_plugins/ui/_impl/table.py
Outdated
|
||
def __init__( | ||
self, | ||
data: TableData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's kind of ugly, but can you inline this type? That makes the docs / autocomplete more useful to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that might also make the type error in the docs CI go away. Otherwise you can replace the |
with Union
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switched to union, and inline here (where its used in the docs), but kept everywhere else DRYed up
|
||
class WebComponentEncoder(JSONEncoder): | ||
"""Custom JSON encoder for WebComponents""" | ||
|
||
def default(self, obj: Any) -> Any: | ||
# Handle numpy objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
marimo/_plugins/ui/_impl/table.py
Outdated
|
||
**Initialization Args.** | ||
|
||
- `data`: a list of values representing a column, or a list of dicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update doc to mention that data
can be a dataframe? I'd start with that.
"A pandas dataframe, or a list of values representing a column, or a list of dicts ...
marimo/_plugins/ui/_impl/table.py
Outdated
```python | ||
# df is a Pandas dataframe | ||
table = mo.ui.table( | ||
data=df.to_dict('records'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove to_dict
marimo/_plugins/ui/_impl/table.py
Outdated
list[dict[str, str]], | ||
Sequence[str | int | float | bool | MIME | None], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need list[dict[str, str]]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically our values in the dicts need to be homegenious. this makes the typings super ugly, so i removed this and just type ignored the response from to_dicts
d7dcfa0
to
6da8c03
Compare
No description provided.