From an API

We can now easily create Series and DataFrames from data we have in Python or from files we are given, but how can we get data from online resources? Each data source is not guaranteed to give us data in the same format, so we have to remain flexible in our approach and be comfortable examining the data source to find the appropriate import method. Let's request some earthquake data from the USGS API and see how we can make a dataframe out of the result.

For this section, we will use 3-making_dataframes_from_api_requests.ipynb, so we have to import the packages we need once again. As with the previous notebook, we need pandas and datetime, but we also need the requests package to make API requests:

>>> import datetime>>> import ...

Get Hands-On Data Analysis with Pandas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.