1. Học hỏi
  2. /
  3. Khoa Học
  4. /
  5. Analyzing IoT Data in Python

Connected

Bài tập

Analyzing Energy counter data

Simply plotting energy counter data will not show anything other than 2 straight lines.

The energy counter gives you a running total, but what you really care about his how much energy was consumed between each measurement.

You need to calculate the difference between 2 consecutive values to see how much energy has been consumed in each interval. Creating the percentage-change from the difference allows for easier comparison and allows new insights.

pandas has already been imported as pd, and matplotlib.pyplot as plt. The DataFrame is available as df.

Hướng dẫn 1/3

undefined XP
  • 1

    Create a new DataFrame called df_diff that contains the difference between values in consecutive rows for all columns.

  • 2

    Downsample df into 30 minute bins, using max() and store the result in df_res to remove noise.

  • 3

    Calculate the percentage changes between consecutive rows in df_diff and store the result in df_pct.