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

Eksik değerleri atama

Eksik veri noktaların olduğunda, bunları nasıl doldurabilirsin?

Bu egzersizde, bazı eksik değerleri doldurmak için farklı enterpolasyon yöntemlerini kullanmayı ve her seferinde sonucu görselleştirmeyi pratik yapacaksın. Ama önce, eksik veri noktalarını enterpole edip çizdirmek için kullanacağın (interpolate_and_plot()) fonksiyonunu oluşturacaksın.

Tek bir zaman serisi, prices adlı bir DataFrame olarak yüklendi.

Bu egzersiz

Python ile Zaman Serisi Verileri için Machine Learning

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

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create a function we'll use to interpolate and plot
def interpolate_and_plot(prices, interpolation):

    # Create a boolean mask for missing values
    missing_values = prices.____()

    # Interpolate the missing values
    prices_interp = prices.____(interpolation)

    # Plot the results, highlighting the interpolated values in black
    fig, ax = plt.subplots(figsize=(10, 5))
    prices_interp.plot(color='k', alpha=.6, ax=ax, legend=False)
    
    # Now plot the interpolated values on top in red
    prices_interp[missing_values].plot(ax=ax, color='r', lw=3, legend=False)
    plt.show()
Kodu Düzenle ve Çalıştır