Back to bricks list
Introduction Version

Jupyter notebook

The Codelab supports Jupyter notebook files ! Here is the VsCode documentation for Jupyter notebook and how to use them : https://code.visualstudio.com/docs/datascience/jupyter-notebooks



Jupyter notebook in Codelab


Here are few tips to use the Jupyter notebook in Codelab.


Organisation


We recommend using the Jupyter notebook only for testing and developing (like live tasks) purpose. It is not recommended to analyse real data as you will lose the potentiel of the Constellab platform.


You can create your notebook inside the notebooks folder (you will find an exemple here).


Data


You can upload the data you want to test in the data folder (with drag and drop in vscode). If you manage big data, the Jupyter notebook might not be best option to analyse them. It is recommended to test your code with small data and use big data in the lab.



Load gws environment


If you want to use the gws environment (brick and packages) you will need to use the env.py script. This script will load the complete environment (bricks, tasks, resources...) and you will be able to use them. Here is how to activate and use the gws environment.


import env     
cwd = env.activate()    #activate GWS environment -> cwd will contain the current working dir as abolute path
# The import of any brick after the env.activate
from gws_core import Table, File, TableImporter
# create a File resource
file = File('/lab/user/data/iris.csv')
# Import the File to Table
table: Table = TableImporter.call(file, {"header": 0})
# transpose the table
result = table.transpose()
# print result Dataframe
print(result.get_data())


This code import a Table from a csv file (placed in the data folder). The use the transpose method of the table to transpose it. And print the Dataframe.



Use R in Jupyter notebook


This is possible to use R in Jupyter notebook, please check the following link : https://constellab.community/tech-doc/doc/developer-guide/dev-environment-v2/r-environment