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
© 2024 OneMinuteCode. All rights reserved.