This script illustrates the first phase of the 'World Food Programme: Food Price and Affordability Analysis' project. The project is using data from the World Food Programme Price Database.
The World Food Programme is monitoring the price of staple foods included in a basic food basket across 99 countries. In the World Food Programme Price Database, the data is stored and can be downloaded at a country level. I aim to merge the available data to gain a global perspective on food price dynamics. The following Python code was used to create a combined food price data set in 3 steps:
- Scraping
With the list of URLs from 'wfp_countries_global.csv' I can gain access to each page on OCHA Services where the food price data for each country can be downloaded in a.csv format. Using BeautifulSoup, I've scraped each of the pages to retrieve the links to the individual country data.
- Using a for loop to download 99 individual data sets
Using the list of links to the individual data sets, I've created a for loop to download all the files.
- Combining the data into a single data set
Using pd.concat, I combined the data from the 99 individual data sets into one single dataframe and exported it for further analysis.