Comments (8)
I have the same issue while ioiterate through my dataframes!!!! :(
from traittypes.
I don't know anything specific about your cases, but in general ValueError: Can't clean for JSON
means some widget trait was not correctly serialized. To be able to offer any help at all, you would need to share a minimal example we can run to reproduce the error.
from traittypes.
I have the same issue, and everything worked before I added an Array
trait using this library ...
from traittypes.
If someone could please share some code to reproduce this error I might be able to help.
from traittypes.
@vidartf Here's my minimum contrived example that produces this bug:
from IPython import get_ipython
import datetime
import pandas as pd
def dataframe_formatter(df):
return { 'application/the21st': { 'rows': [{'datetime': datetime.time(10, 0) }]} }
get_ipython().display_formatter.mimebundle_formatter.for_type(pd.DataFrame, dataframe_formatter)
Displaying any dataframe in jupyter then produces an error with stack trace:
error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-ed84ad4d2d82> in <module>
---> 1 df
/opt/venv/lib/python3.7/site-packages/IPython/core/displayhook.py in __call__(self, result)
264 self.fill_exec_result(result)
265 if format_dict:
--> 266 self.write_format_data(format_dict, md_dict)
267 self.log_output(format_dict)
268 self.finish_displayhook()
/opt/venv/lib/python3.7/site-packages/ipykernel/displayhook.py in write_format_data(self, format_dict, md_dict)
69
70 def write_format_data(self, format_dict, md_dict=None):
---> 71 self.msg['content']['data'] = json_clean(encode_images(format_dict))
72 self.msg['content']['metadata'] = md_dict
73
/opt/venv/lib/python3.7/site-packages/ipykernel/jsonutil.py in json_clean(obj)
189 out = {}
190 for k,v in iteritems(obj):
--> 191 out[unicode_type(k)] = json_clean(v)
192 return out
193 if isinstance(obj, datetime):
/opt/venv/lib/python3.7/site-packages/ipykernel/jsonutil.py in json_clean(obj)
189 out = {}
190 for k,v in iteritems(obj):
--> 191 out[unicode_type(k)] = json_clean(v)
192 return out
193 if isinstance(obj, datetime):
/opt/venv/lib/python3.7/site-packages/ipykernel/jsonutil.py in json_clean(obj)
175
176 if isinstance(obj, list):
--> 177 return [json_clean(x) for x in obj]
178
179 if isinstance(obj, dict):
/opt/venv/lib/python3.7/site-packages/ipykernel/jsonutil.py in <listcomp>(.0)
175
176 if isinstance(obj, list):
--> 177 return [json_clean(x) for x in obj]
178
179 if isinstance(obj, dict):
/opt/venv/lib/python3.7/site-packages/ipykernel/jsonutil.py in json_clean(obj)
189 out = {}
190 for k,v in iteritems(obj):
--> 191 out[unicode_type(k)] = json_clean(v)
192 return out
193 if isinstance(obj, datetime):
/opt/venv/lib/python3.7/site-packages/ipykernel/jsonutil.py in json_clean(obj)
195
196 # we don't understand it, it's probably an unserializable object
--> 197 raise ValueError("Can't clean for JSON: %r" % obj)
ValueError: Can't clean for JSON: datetime.time(10, 0)
from traittypes.
@the21st But that code doesn't use the traittypes
package at all. Could you explain a little more what code in this repo that example is relevant for?
from traittypes.
@vidartf you're right. I think it might an issue in ipykernel
that's the root cause. Just wanted to illustrate how it might happen.
Edit: I opened an issue there ipython/ipykernel#546
from traittypes.
Well, as there isn't a standard JSON primitive for dates, you would be responsible for serializing the data/datetime/time object yourself.
from traittypes.
Related Issues (20)
- Transfer ownership to jupyter-widgets? HOT 1
- PIL Image HOT 2
- Please Add LICENSE HOT 1
- Serializers for ndarrays HOT 4
- Release 0.2.0 HOT 2
- There is no such thing in just traitlets as Sentinel HOT 10
- nan support
- test_bad_values (traittypes.tests.test_traittypes.TestIntArray) fails for openSUSE
- creating instance with Undefined is not meant to assign Undefined HOT 1
- Traitlets Upstream Integration Tests Broken
- DeprecationWarning HOT 8
- test fails on Debian/Testing with traitlets 5.0.4 with python 3.8
- Can't use link with Array HOT 3
- 0.2.1: test suite is using deprecated `nose` module and pytest is failing in one unit HOT 3
- DeprecationWarning: Sentinel is not a public part of the traitlets API. It was published by mistake, and may be removed in the future.
- Is this repository still maintained?
- Remove use of `_notify_trait`
- Custom validation of single traittypes HOT 9
- Roadmap HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from traittypes.