데이터 이해하기

Python으로 IoT 데이터 분석하기

Matthias Voppichler

IT Developer

데이터를 디스크에 저장

IoT 데이터를 저장하는 이유

  • 제한된 과거 데이터 가용성
  • 결과 재현 가능성
  • ML 모델 학습
Python으로 IoT 데이터 분석하기

pandas로 데이터 저장

df_env.to_json("data.json", orient="records")
!cat data.json

[{'timestamp': 1536924000000, 'value': 22.3}, {'timestamp': 1536924600000, 'value': 22.8}, {'timestamp': 1536925200000, 'value': 23.3}, {'timestamp': 1536925800000, 'value': 23.6}, {'timestamp': 1536926400000, 'value': 23.5}]
Python으로 IoT 데이터 분석하기

저장 데이터 읽기

  • JSON 파일에서
import pandas as pd
df_env = pd.read_json("data.json")
  • CSV 파일에서
import pandas as pd
df_env = pd.read_csv("data.csv")
Python으로 IoT 데이터 분석하기

데이터 로드 검증

  • 열 이름이 올바른가
  • 데이터 형식 확인
df_env.head()
            timestamp  humidity  pressure  sunshine  temperature
0 2018-09-01 00:00:00      95.6    1016.3     599.2         16.1
2 2018-09-01 00:10:00      95.5    1016.4     600.0         16.1
4 2018-09-01 00:20:00      95.2    1016.5     598.9         16.1
6 2018-09-01 00:30:00      95.1    1016.4     600.0         16.1
8 2018-09-01 00:40:00      95.3    1016.3     600.0         16.1
Python으로 IoT 데이터 분석하기

DataFrame.info()

df_env.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 13085 entries, 0 to 13085
Data columns (total 5 columns):
pressure                13085 non-null float64
humidity                13085 non-null float64
sunshine                13083 non-null float64
temperature             13059 non-null float64
timestamp               13085 non-null datetime64[ns]

dtypes: datetime64[ns](1), float64(6)
memory usage: 1.4 MB
Python으로 IoT 데이터 분석하기

pandas describe()

df_env.describe()
           humidity      pressure      sunshine  temperature
count  13057.000000  13057.000000  13057.000000  13057.00000
mean      73.748350   1019.173003    187.794746     14.06647
std       20.233558      6.708031    274.094951      6.61272
min        8.900000    989.500000      0.000000     -1.80000
25%       57.500000   1016.000000      0.000000      9.80000
50%       78.800000   1019.700000      0.000000     13.40000
75%       91.300000   1023.300000    598.900000     18.90000
max      100.100000   1039.800000    600.000000     30.40000
Python으로 IoT 데이터 분석하기

연습해 봅시다!

Python으로 IoT 데이터 분석하기

Preparing Video For Download...