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

Median prices

There are times when the median is a better tool than the mean. Lets imagine that you are analyzing the stock data in the DataFrame prices again. You want to know if the stock's price is trending down by comparing the opening and closing prices. Remember the DataFrame has the columns OPEN, HI, LOW, and CLOSE.

Bu egzersiz

Intermediate Python for Finance

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

Egzersiz talimatları

  • Calculate the median of the opening prices.
  • Calculate the median of the closing prices.
  • Compare the opening and closing medians to get the trend.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Get the median of the opening prices
med_open = ____.loc[:, '____'].____()

# Get the median of the closing prices
med_close = ____.____[:, '____'].____()

if ____ > ____:
    print("Trending down.")
Kodu Düzenle ve Çalıştır