Reputation: 1721
How to have a http response JSON to Pandas DataFrame
r = requests.post(url, data=payload, headers=headers)
r.text
'{\n "Process": "[1, 1]"\n}\n'
How to take this "Process": "[1, 1]" from the r.text to a DataFrame with 'Process' as colunm name and 1,1 as valuess in each row. In this case , we can expect output dataFrame with one Column 'Process' and 2 rows
Upvotes: 0
Views: 122
Reputation: 59274
You may use ast
and json.loads
import ast
import json
x = {k: ast.literal_eval(v) for k,v in json.loads(s).items()}
df = pd.DataFrame(x)
Upvotes: 1