價格中位數
有時候中位數比平均數更合適。想像你再次在分析 DataFrame prices 的股票資料。你想透過比較開盤價與收盤價,判斷股價是否呈現下跌走勢。請記得,這個 DataFrame 包含 OPEN、HI、LOW 與 CLOSE 這些欄。
本練習屬於課程
Intermediate Python for Finance
練習說明
- 計算開盤價的中位數。
- 計算收盤價的中位數。
- 比較開盤與收盤的中位數,判斷走勢。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Get the median of the opening prices
med_open = ____.loc[:, '____'].____()
# Get the median of the closing prices
med_close = ____.____[:, '____'].____()
if ____ > ____:
print("Trending down.")