-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Better dataframe formatting in REPL #15555
Comments
I haven't documented this yet, but you can use the following to get a richer table:
Zed/GPUI does not support HTML output at this time so we are using the JSON Schema output for now. |
@rgbkrk for dataframe objects, how exactly are they serialized to the repl? i saw that there is the rank_mime_type that'll use Is there a dunder method or other AFAIK, only pandas supports the afformentioned option for |
It also looks like data tables are truncating the last column. Screen.Recording.2024-08-01.at.12.13.01.PM.mov |
The media type this goes on is class DataResource:
def __init__(self, data):
self.data = data
# The media type for this is `application/vnd.dataresource+json`.
# The only `_repr*_` method to emit this is to use `_repr_mimebundle_`.
# For more details, refer to: https://ipython.readthedocs.io/en/stable/config/integrating.html
def _repr_mimebundle_(self, include=None, exclude=None):
return {
'application/vnd.dataresource+json': self.data
}
# Example usage
data = {
"schema": {
"fields": [
{"name": "name", "type": "string"},
{"name": "age", "type": "integer"}
]
},
"data": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25}
]
}
resource = DataResource(data)
resource You can also use |
Check for existing issues
Describe the feature
When you display a dataframe via the REPL, the formatting is very bad. I tried this with multiple dataframe libraries (polars, daft, pandas). They should use
_repr_html_
as is customary with jupyter notebooks, but it looks like instead they are using the__repr__
method.The
__repr__
method would be fine if it was properly aligned as it is in vscodeIf applicable, add mockups / screenshots to help present your vision of the feature
Zed
VSCode
VSCode
__repr__
The text was updated successfully, but these errors were encountered: