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

4
  • Have you confirmed that you are receiving data from requests? Commented Jan 7, 2019 at 19:19
  • I'm getting a 403 response from that page. Commented Jan 7, 2019 at 19:20
  • hey Daniel, yes I am. I haven't shared my API key publicly here. You will see in the URL I've replaced my API key with "my_key" @DanielScott Commented Jan 7, 2019 at 19:22
  • Great, and have you confirmed that it is real json? If the json snippet is small, can you post it here? Commented Jan 7, 2019 at 19:23

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

this works. Thanks so much

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.