Reputation: 65
from this code:
response=session.get(urllink)
tabella=pd.read_json(response.content)
data=tabella["table"]
print(data)
I get this dictionary (or I think it is a dictionary), how could I create a dataframe with AAA,BBB,CCC as columns name and all the data ordered in columns?
0 {'AAA': '111', 'BBB': '111', 'CCC': '111',...
1 {'AAA': '222', 'BBB': '222', 'CCC': '222',...
2 {'AAA': '333', 'BBB': '333', 'CCC': '333',...
3 {'AAA': '444', 'BBB': '444', 'CCC': '444',...
4 {'AAA': '555', 'BBB': '555', 'CCC': '555',...
...
Name: table, Length: 200, dtype: object```
I tried with
df=pd.DataFrame.from_dict(data)
but I get the same result as before
Upvotes: 3
Views: 88
Reputation: 195418
Try applying pd.Series
on the column:
print(df["table"].apply(pd.Series))
Prints:
AAA BBB CCC
0 111 111 111
1 222 222 222
2 333 333 333
3 444 444 444
4 555 555 555
Upvotes: 2