Skip to content
Snippets Groups Projects
Commit 8330bd9d authored by ch36's avatar ch36
Browse files

Upload New File

parent 5cb6d240
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
<p>
<img src="https://s3.amazonaws.com/iotanalytics-templates/Logo.png" style="float:left;width:65px">
<h1 style="float:left;color:#1A5276;padding-left:15px;font-size:20px;">AWS IoT Analytics | Notebook</h1>
</p>
%% Cell type:markdown id: tags:
When loading data from IoT Analytics datasets, the client should be initialized first:
%% Cell type:code id: tags:
``` python
import boto3
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# create IoT Analytics client
client = boto3.client('iotanalytics')
```
%% Output
Matplotlib is building the font cache; this may take a moment.
/home/ec2-user/anaconda3/envs/amazonei_mxnet_p36/lib/python3.6/site-packages/boto3/compat.py:88: PythonDeprecationWarning: Boto3 will no longer support Python 3.6 starting May 30, 2022. To continue receiving service updates, bug fixes, and security updates please upgrade to Python 3.7 or later. More information can be found here: https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/
warnings.warn(warning, PythonDeprecationWarning)
%% Cell type:markdown id: tags:
Now we can get the data location (URL) for the given dataset and start working with the data (In order to need to perform get_dataset_content, you need to grant iot analytics corresponding IAM permission):
%% Cell type:code id: tags:
``` python
dataset_url = client.get_dataset_content(datasetName = dataset)['entries'][0]['dataURI']
data = pd.read_csv(dataset_url)
```
%% Cell type:code id: tags:
``` python
emissions = np.array(data["emission"])
plt.plot(np.arange(emissions.shape[0]), emissions)
plt.title('CO2 emissions')
plt.xlabel('ID')
plt.ylabel('emission')
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
max_emmision = 0
max_emmisions = emissions
for i in range(emissions.shape[0]):
max_emmision = max(max_emmision, emissions[i])
max_emmisions[i] = max_emmision
plt.plot(np.arange(max_emmisions.shape[0]), max_emmisions)
plt.title('CO2 emissions')
plt.xlabel('ID')
plt.ylabel('max emission')
plt.show()
```
%% Output
%% Cell type:markdown id: tags:
<div style="height:60px;"><div style="height:7px;background-color:#20B3CD;width:100%;margin-top:20px;position:relative;"><img src="https://s3.amazonaws.com/iotanalytics-templates/Logo.png" style="height:50px;width:50px;margin-top:-20px;position:absolute;margin-left:42%;"></div></div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment