데이터 집계값 시각화

Python으로 시계열 데이터 시각화

Thomas Vincent

Head of Data Science, Getty Images

이동 평균

  • 시계열 분석에서 이동 평균은 다양한 목적으로 활용됩니다:
    • 단기 변동 평활화
    • 이상값 제거
    • 장기 추세 또는 주기 강조
Python으로 시계열 데이터 시각화

이동 평균 모델

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()
Python으로 시계열 데이터 시각화

CO2 데이터의 이동 평균 시각화

시계열의 이동 평균 그래프

Python으로 시계열 데이터 시각화

시계열 집계값 계산

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)
Python으로 시계열 데이터 시각화

시계열 집계값 시각화

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

plt.show()
Python으로 시계열 데이터 시각화

시계열 집계값 시각화

CO2 수준 데이터의 월별 집계

Python으로 시계열 데이터 시각화

연습해 봅시다!

Python으로 시계열 데이터 시각화

Preparing Video For Download...