Reprezentarea agregatelor datelor

Vizualizarea datelor de tip serie temporală în Python

Thomas Vincent

Head of Data Science, Getty Images

Medii mobile

  • În analiza seriilor de timp, media mobilă poate fi utilizată în mai multe scopuri:
    • atenuarea fluctuațiilor pe termen scurt
    • eliminarea valorilor aberante
    • evidențierea tendințelor sau ciclurilor pe termen lung.
Vizualizarea datelor de tip serie temporală în Python

Modelul mediei mobile

co2_levels_mean = co2_levels.rolling(window=52).mean()

ax = co2_levels_mean.plot()
ax.set_xlabel("Date")
ax.set_ylabel("The values of my Y axis")
ax.set_title("52 weeks rolling mean of my time series")

plt.show()
Vizualizarea datelor de tip serie temporală în Python

Graficul mediei mobile pentru datele CO2

Media mobilă a unei serii de timp

Vizualizarea datelor de tip serie temporală în Python

Calcularea valorilor agregate ale seriei de timp

co2_levels.index
DatetimeIndex(['1958-03-29', '1958-04-05',...],
              dtype='datetime64[ns]', name='datestamp', 
              length=2284, freq=None)
print(co2_levels.index.month)
array([ 3,  4,  4, ..., 12, 12, 12], dtype=int32)
print(co2_levels.index.year)
array([1958, 1958, 1958, ..., 2001,
      2001, 2001], dtype=int32)
Vizualizarea datelor de tip serie temporală în Python

Reprezentarea valorilor agregate ale seriei de timp

index_month = co2_levels.index.month
co2_levels_by_month = co2_levels.groupby(index_month).mean()
co2_levels_by_month.plot()

plt.show()
Vizualizarea datelor de tip serie temporală în Python

Reprezentarea valorilor agregate ale seriei de timp

Agregate lunare ale datelor privind nivelurile de CO2

Vizualizarea datelor de tip serie temporală în Python

Să exersăm!

Vizualizarea datelor de tip serie temporală în Python

Preparing Video For Download...