0

I am request data from the Zoopla API, going through each of the page and then finally trying to append the data in a dataframe. I am using the following code:

raw_data = pd.DataFrame([])

for i in range(1,5):
    r = requests.get('http://api.zoopla.co.uk/api/v1/property_listings.json?area=Nottingham&api_key=my_key&page_size=20&page_number='+str(i))
    data = r.json()
    df_temp = pd.DataFrame.from_dict(data['listing'])
    raw_data.append(df_temp,ignore_index=True,sort=False)

The code above, however, doesn't append any data to raw_data at all.

raw_data.shape // returns (0,0) after the for loop.

Note: I haven't shared my API key in the url above. I can confirm that I am receiving data from the API

Nant
  • 569
  • 2
  • 10
  • 24

1 Answers1

1

Append isn't an inplace operation by default. You can fix it by changing to

raw_data = raw_data.append(df_temp,ignore_index=True,sort=False)
Allen
  • 236
  • 3
  • 12