-
Time Series 데이터를 시각화pandas 2022. 10. 25. 21:28
문제
1초 단위로 저장된 2분간의 데이터(0~500 사이의 값) 를 10초 단위로 나누어 평균값을 시각화 한다.
코드
import pandas as pd import numpy as np import plotly.express as px rng = pd.date_range("1/1/2012", periods=120, freq="S") # freq="S" 초 단위로 ts = pd.Series(np.random.randint(0, 500, len(rng)), index=rng) df = ts.resample('10S').aggregate(np.average) # 10초 단위로 grouping 후 평균을 구함 fig = px.line(df) fig.show()
결과
'pandas' 카테고리의 다른 글
데이터 전처리, 추가, 삭제, 변환 (0) 2022.10.08 복사와 결측치 (0) 2022.10.08 통계 (0) 2022.10.08 조회, 정렬, 필터 (0) 2022.08.20 Excel, CSV 파일 읽기/쓰기 (0) 2022.08.19