{"key1":"value1", "key2":"value2", "key3":"value3", "key4":"value4"}
{"key1":"value1", "key2":"value2", "key3":"value3" ,"key4":"value4" }
{"key1":"value1", "key2":"value2", "key3":"value3" ,"key4":"value4" }
{"key1":"value1", "key2":"value2", "key3":"value3" ,"key4":"value4" }
{"key1":"value1", "key2":"value2", "key3":"value3" ,"key4":"value4" }
When I read the content by requesting api, it is read as above.
The original is bytes, and it is also used by decoding and converting it into string How can I make this structure into a data frame?
python dataframe
>>> import json"
>>> import pandas as df
>>> a = '{"key1":"value1", "key2":"value2", "key3":"value3" ,"key4":"value4" }'
>>> a
'{"key1":"value1", "key2":"value2", "key3":"value3" ,"key4":"value4" }'
>>> type(a)
<class 'str'>
>>> b = json.loads(a)
>>> b
{'key1': 'value1', 'key2': 'value2', 'key3': 'value3', 'key4': 'value4'}
>>> type(b)
<class 'dict'>
>>> g = df.DataFrame.from_dict(b, orient='index')
>>> g
0
key1 value1
key2 value2
key3 value3
key4 value4
Is this right?
© 2024 OneMinuteCode. All rights reserved.