Analyzing IoT Data in Python Chapter2
Analyzing IoT Data in Python Chapter2
A N A LY Z I N G I OT D ATA I N P Y T H O N
Matthias Voppichler
IT Developer
Plot dataframe
df.plot(title="Environment")
Matthias Voppichler
IT Developer
Missing data
Reasons for missing data from IoT devices
No power
During analysis
ll
mean
median
forward- ll
backward- ll
drop
stop analysis
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 12 entries, 2018-10-15 08:00:00 to 2018-10-15 08:55:00
Data columns (total 3 columns):
temperature 8 non-null float64
humidity 8 non-null float64
precipitation 12 non-null float64
dtypes: float64(3)
memory usage: 384.0 bytes
df.dropna()
df.fillna(method="ffill")
print(df.isna().sum()) print(df_res.isna().sum())
temperature 0 temperature 34
humidity 0 humidity 34
dtype: int64 dtype: int64
Matthias Voppichler
IT Developer
What is caching?
storing data
After data stream collection
Observation by observation
Creates high load on Disks
Use caching
with Path("data.txt").open("a") as f:
f.writelines(cache)
cache.clear()
message.timestamp
datetime.now()
consume_time = datetime.utcnow()
import pandas as pd
df["timestamp"] = pd.to_datetime(df["timestamp"], unit="ms")
Matthias Voppichler
IT Developer
Data preparation
Pivot data
Resample
Apply diff()
Apply pct_change()