Visualize the long-term oil price trend
In the previous video, you learned how to retrieve data from the Federal Reserve Economic Data (FRED) portal.
Here, you will use this new data source to visualize the oil price trend over the last 50 years, specifically, the Spot Crude Oil Price: West Texas Intermediate (WTI). DataReader
, date
, pandas
as pd
, and matplotlib.pyplot
as plt
have been imported.
Este ejercicio forma parte del curso
Importing and Managing Financial Data in Python
Instrucciones del ejercicio
- Use
date()
to setstart
to January 1, 1968, and setseries
to series code'WTISPLC'
. - Pass
series
as the data,'fred'
as the data source, andstart
as the start date toDataReader()
. Assign tooil_price
. - Inspect
oil_price
using.info()
. - Plot and show the
oil_price
series with title'Oil Price'
.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Set start date
start = ____
# Set series code
series = 'WTISPLC'
# Import the data
oil_price = DataReader(____, ____, start=____)
# Inspect the price of oil
oil_price.info()
# Plot the price of oil
____
# Show the plot
plt.show()