A simple way to save and rewrite a data frame imported into requests.

Asked 2 years ago, Updated 2 years ago, 36 views

We created a function that calls api and saves it in dataframe format as follows:
I want to save the returned df value somewhere else and use it when creating another function.
What's the way? I don't want to duplicate list() so I don't want to write list() in a new function)

For example, if you call function a and function b from another function and combine them, both functions require df of the list. This means that the list() is called in duplicate as soon as the two functions are called together. Therefore, you do not want to call by saving the return value of list() elsewhere.

def list():
    headers = {
        'Authorization': 'Bearer ' + accesstoken,
        'Id': id,
    }
    r1 = requests.get(url, headers=headers)
    r1_json = r1.json()
    df = pd.DataFrame(data=r1_json['content'])
    return df

python api function

2022-09-20 19:34

1 Answers


2022-09-20 19:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.