Hope you can help.
I need to transform my request data into dataframes, but have some problems.
My code look like this so far:
import requests
import json
from pandas.io.json import json_normalize
url = "https://api-football-v1.p.rapidapi.com/v2/teams/league/442"
headers = {
'x-rapidapi-host': "api-football-v1.p.rapidapi.com",
'x-rapidapi-key': "My-rapidapikey-Not-Showing"
}
dict_train = requests.request("GET", url, headers=headers).json()
train = pd.DataFrame.from_dict(dict_train, orient='index')
train.reset_index(level=0, inplace=True)
train
It gives me this.
The data in text, looks like this.
How can I transform my data into dataframes with the right column names? For this it would be "name", "code", "flag", "country" and so on, and make it flexible when I call the api with different requests?
I tried to follow some of the things from here, without success: JSON to pandas DataFrame
Thank you!