Jupyter Notebook

This tutorial aims to help you and provides guidelines on how to use Wizata Python Toolkit on Jupyter Notebook.

Installation

Ensure your are running a notebook on Python 3.9

from platform import python_version
print(python_version())

Make sure you have installed wizata_dsapi on your environment. If not, please use import wizata_dsapi

Set environment variables to connect to Wizata (see configuration)

%env WIZATA_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
%env WIZATA_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
%env WIZATA_SCOPE=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/api
%env WIZATA_DOMAIN=xxx-wizard.onwizata.com
%env [email protected]
%env WIZATA_PASSWORD=xxxxxxxxxxx

๐Ÿšง

Donโ€™t use double quotation (โ€) in variable value!

Fetch a Dataframe

The โ€˜clientโ€™ can be easily accessed and generated thanks to environment variables and api() attribute: wizata_dsapi.api()

You can fetch data from Wizata using a simple query like this one :

from datetime import datetime
import pandas

df = wizata_dsapi.api().query(
    datapoints=["<hardwareid_XX>","<hardwareid_XY>"],
    start=datetime.strptime("2023-01-01","%Y-%m-%d"),
    end=datetime.strptime("2023-01-02","%Y-%m-%d"),
    interval=60000
)

Develop functions

Create and test your function(s) locally

def notebook_sample(df):
    return df
notebook_sample(df)

๐Ÿ“˜

As a reminder, you can transform data, plot them or train models.

Once your solutions are ready, upload, test and validate them.

wizata_dsapi.api().upsert(notebook_sample)

result = wizata_dsapi.api().test(script='notebook_sample',dataframe=df)

print(wizata_dsapi.api().validate(script='notebook_sample',dataframe=df).status)

Show plots

You can visualize any wizata plot within your notebook. Use the helper method wizata_dsapi.api().plot(), you can pass an id, a figure or a Wizata DS API Plot object.

wizata_dsapi.api().plot('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')

wizata_dsapi.api().plot(figure=myfigure)

wizata_dsapi.api().plot(plot=wizata_dsapi_plot)