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

"TypeError: Type is not JSON serializable: Timestamp" when outputting Dataframe with pd.Timestamp column in Code Interpreter #510

Open
antonioalegria opened this issue Dec 18, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@antonioalegria
Copy link

Describe the bug

When outputting Pandas dataframes with pd.Timestamp columns, the following exception is raised by E2B:

---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last)File /usr/local/lib/python3.10/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)
File ~/.ipython/profile_default/startup/0002_data.py:23, in _dataframe_repr_e2b_data_(self)
     22 def _dataframe_repr_e2b_data_(self: pandas.DataFrame):
---> 23     return orjson.loads(orjson.dumps(self.to_dict(orient="list")))
TypeError: Type is not JSON serializable: Timestamp"

To Reproduce
Run the following code in a code interpreter sandbox:

# Get social accounts (with timestamp field)
df = pd.DataFrame({'timestamp': [pd.Timestamp('2024-01-01T00:00:00Z')], 'name': ['John Smith']})
print(df)
display(df)

Expected behavior

It should not fail to convert the timestamp fields into a string representation in JSON.

Versions

e2b: 1.0.5
e2b-code-interpreter: 1.0.3

@antonioalegria antonioalegria added the bug Something isn't working label Dec 18, 2024
@antonioalegria
Copy link
Author

Hi folks, happy new year! Any update on this issue? Thanks!

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

No branches or pull requests

2 participants