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

Handle missing values

In order to replace missing values in your time series data, you can use the command:

df = df.fillna(method="ffill")

where the argument specifies the type of method you want to use. For example, specifying bfill (i.e backfilling) will ensure that missing values are replaced using the next valid observation, while ffill (i.e. forward-filling) ensures that missing values are replaced using the last valid observation.

Recall from the previous exercise that co2_levels has 59 missing values.

Bu egzersiz, kursun bir parçasıdır

Visualizing Time Series Data in Python

Kursa Göz Atın

Egzersiz talimatları

  • Impute these missing values in co2_levels by using backfilling.
  • Print the total number of missing values.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Impute missing values with the next valid observation
co2_levels = co2_levels.____(method=____)

# Print out the number of missing values
____(____.____())
Kodu Düzenle ve Çalıştır