Reputation: 87
I can't find why this is happening. Can i get a justification ?
using pandas in python, if I write in the console:
pd.io.json.read_json('{"rCF":{"values":0.05}}')
I got printed a dataframe that looks like this
rCF
values 0.05
This if fine.
But if I write in the console:
pd.io.json.read_json('[{"rCF":{"values":0.05}}]')
I got printed a dataframe that looks like this
rCF
0 {u'values': 0.05}
in particular, why the key is u'values' and not just 'values'
Upvotes: 0
Views: 234
Reputation: 881805
json
always decodes to Unicode:
>>> import json
>>> json.loads('{"a":"b"}')
{u'a': u'b'}
It's just that in your former case a print
or the equivalent somewhere inside pandas
is hiding this, as would, e.g:
>>> x = _
>>> for k in x: print k
...
a
after the above snippet; but when you print
(or the like) a container, you get to see the more precise repr
of the container's items.
Upvotes: 2