BaşlayınÜcretsiz Başlayın

Compare the performance of several asset classes

You have seen in the video how you can easily compare several time series by normalizing their starting points to 100, and plot the result.

To broaden your perspective on financial markets, let's compare four key assets: stocks, bonds, gold, and oil.

Bu egzersiz

Manipulating Time Series Data in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

We have already imported pandas as pd and matplotlib.pyplot as plt.

  • Import 'asset_classes.csv', using .read_csv() to parse dates in the 'DATE' column and set this column as the index, then assign the result to prices.
  • Select the first price for each series using .iloc[0] on prices and assign the result to first_prices.
  • Divide prices by first_prices, multiply by 100 and assign the result to normalized.
  • Plot normalized.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import data here
prices = ____

# Inspect prices here
print(____)

# Select first prices
first_prices = ____

# Create normalized
normalized = ____

# Plot normalized

Kodu Düzenle ve Çalıştır