Missing DataFrame index in `Result.data`
@jakubno đang làm issue này rồi.
Từ ngày 23/4/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
When a DataFrame is displayed, the corresponding Result has the data attribute in the format {column -> [values]} (equivalent to df.to_dict(orient="list")). This means that we lose the table index, which can be relevant. Is it possible to use a format that preserves this information?
To keep consistency with pandas' to_dict, any of these options would work:
- 'dict' (default) : dict like
{column -> {index -> value}} - 'split' : dict like
{'index' -> [index], 'columns' -> [columns], 'data' -> [values]} - 'tight' : dict like
{'index' -> [index], 'columns' -> [columns], 'data' -> [values], 'index_names' -> [index.names], 'column_names' -> [column.names]} - 'index' : dict like
{index -> {column -> value}}
(Note: 'tight' is the only option that preserves the full information, including the index name)
Example
from e2b_code_interpreter import Sandbox
code = """
import pandas as pd
df = pd.DataFrame({"key": ["a", "b", "a", "b"], "value": [1, 2, 3, 4]})
display(df.groupby("key").sum())
"""
with Sandbox() as sandbox:
execution = sandbox.run_code(code)
result = execution.results[0]
print("Text:")
print(result.text)
print("Data:")
print(result.data)
Text:
value
key
a 4
b 6
Data:
{'value': [4, 6]}
Expected (one of the options):
Data:
{'index': ['a', 'b'], 'columns': ['value'], 'data': [[4], [6]], 'index_names': ['key'], 'column_names': [None]}
- Ngôn ngữ chính
- Python
- Star
- 2.4k
- Fork
- 228
- Merge trung bình
- 48 phút
- Pull request đã merge (30 ngày)
- 5
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của e2b-dev/code-interpreter
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
e2b-dev/code-interpreter#326 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
e2b-dev/code-interpreter#251 · 2 bình luận ·
-
Dependency Dashboard Đang mởChore Dashboard
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
e2b-dev/code-interpreter#200 · 2 bình luận ·
-
feature SDK
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
e2b-dev/code-interpreter#190 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
e2b-dev/code-interpreter#165 · 1 bình luận ·
Tất cả issue của e2b-dev/code-interpreter
Issue tương tự
-
bug confirmed issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
open-webui/open-webui#30750 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100