장기 유가 추세 시각화하기
이전 동영상에서 Federal Reserve Economic Data (FRED) 포털에서 데이터를 가져오는 방법을 배웠어요.
여기서는 이 데이터 소스를 사용해 지난 50년간의 유가 추세를 시각화해 보겠습니다. 구체적으로는 Spot Crude Oil Price: West Texas Intermediate (WTI)를 사용합니다. DataReader, date, pandas는 pd로, matplotlib.pyplot은 plt로 이미 임포트되어 있어요.
이 연습은 강의의 일부입니다
Python으로 금융 데이터 가져오기와 관리
연습 안내
date()를 사용해start를 1968년 1월 1일로 설정하고,series는 시리즈 코드'WTISPLC'로 설정하세요.DataReader()에 데이터로series, 데이터 소스로'fred', 시작일로start를 전달하세요. 결과를oil_price에 할당하세요..info()로oil_price를 살펴보세요.- 제목을
'Oil Price'로 하여oil_price시리즈를 플로팅하고 표시하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# 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()