Closed jakubno closed 3 months ago
MVP for easy way to extract data from pandas DataFrames.
data
Result
e2b-code-interpreter==0.0.11b2
Here's a code snippet to try this
import asyncio from e2b_code_interpreter import AsyncCodeInterpreter from dotenv import load_dotenv load_dotenv() CODE = """ import pandas data = { "food": ["bacon", "pulled pork", "oats"], "type": ["meat", "meat", "vegetarian"], "calories": [420, 380, 390], } df = pd.DataFrame(data) df """ CODE2 = """ df2 = df.groupby(["type"]).agg({'calories': 'mean'}) df2 """ async def main(): sandbox = await AsyncCodeInterpreter.create(timeout=180) execution = await sandbox.notebook.exec_cell(CODE) print(execution.results[0].data) # {'food': ['bacon', 'pulled pork', 'oats'], 'type': ['meat', 'meat', 'vegetarian'], 'calories': [420, 380, 390]} execution = await sandbox.notebook.exec_cell(CODE2) print(execution.results[0].data) # {'calories': [400.0, 390.0]} await sandbox.kill() asyncio.run(main())
Description
MVP for easy way to extract data from pandas DataFrames.
data
on theResult
object.Steps to try it out (Python only)
e2b-code-interpreter==0.0.11b2
Here's a code snippet to try this