I have the following code:
responsedata = requests.get(url, data=data, headers=hed, verify=False)
sample_object = pd.DataFrame(responsedata.json())['results'].to_dict()
func(sample_object)
Now, I have another get call using function which does some manipulation over the data:
responsedata2 = get_data(url2)
I do know that:
responsedata2 is equivalent to responsedata.json()['results']
as if I do:
print responsedata2
print responsedata.json()['results']
I will get the same output (If called with the same URL).
My question is how can I create sample_object2 that will be equivalent to sample_object1 so I will be able to do: func(sample_object2)
Any idea how to make it works? It seems simply but the involvement of the DataFrame makes it hard.
Edit:
To explain better what I'm after.
I want to write a function that gets object like responsedata2 and return object like sample_object.
func()andgetdata()do? At present it's not very clear where your problem is.responsedata2and convert it tosample_objectWhen the information you know is thatresponsedata2is the same asresponsedata.json()['results']