Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫:尽管解码,但Json不可序列化_Python_Json_Utf 8_Serializable - Fatal编程技术网

Python 熊猫:尽管解码,但Json不可序列化

Python 熊猫:尽管解码,但Json不可序列化,python,json,utf-8,serializable,Python,Json,Utf 8,Serializable,给出: df['attr1'].unique() df['attr1'] = df['attr1'].str.decode('utf8') df['attr1'].unique() 因此,我用以下方法进行解码: array([b'C84', b'C3', b'C63', b'C60', b'C62', b'C58', b'C31', b'C55']) 给出: df['attr1'].unique() df['attr1'] = df['attr1'].str.decode('utf8')

给出:

df['attr1'].unique()
df['attr1'] = df['attr1'].str.decode('utf8')
df['attr1'].unique()
因此,我用以下方法进行解码:

array([b'C84', b'C3', b'C63', b'C60', b'C62', b'C58', b'C31', b'C55'])
给出:

df['attr1'].unique()
df['attr1'] = df['attr1'].str.decode('utf8')
df['attr1'].unique()
属性值正在使用Bokeh库在弦图中使用,但我认为这不是问题所在。我对另一列“attr2”应用了与前面相同的过程,并使用Bokeh执行了以下操作:

array(['C84', 'C3', 'C63', 'C60', 'C62', 'C58', 'C31', 'C55'])
与json相关的特定错误与以下内容有关:

chord = Chord(df, source='attr1', target="attr2", value="weights")
show(chord)
它尝试序列化为JSON并提供:

json.dumps(obj, cls=BokehJSONEncoder, allow_nan=False, indent=indent, 
separators=separators, sort_keys=True, **kwargs)

Bokeh正在查看以前的数据帧吗?在这种情况下,可能我不是在解码和替换原始数据帧?

您能向我们展示更多的代码吗?比如,您对
json.dump
的调用或其他什么?您能给我们展示更多的代码吗?比如,你对
json.dump
的调用或者其他什么?