> For the complete documentation index, see [llms.txt](https://record-evolution.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://record-evolution.gitbook.io/docs/code-in-workbooks.md).

# Code in Workbooks

A workbook is where you write code and create documents.

To access the workbooks in your data pod, start your data pod and go to the *Analysis* panel.

### [Basic navigation](https://docs.record-evolution.de/#/en/Repods/workbooks?id=basic-navigation) <a href="#basic-navigation" id="basic-navigation"></a>

Workbooks are part of the *Results* layer of your data pod.

The *Results* layer is where you code in data science workbooks and create visualisations in infographics. In this environment, you have an overview of all result entities created within your data pod and grouped by type.

The centerpiece of the *Analysis* section is the *Results* environment where we have a masonry view of all workbooks and infographics within your data pod.

Hit the edit icon to open a workbook and inspect the results.

#### [Workbook concept](https://docs.record-evolution.de/#/en/Repods/workbooks?id=workbook-concept) <a href="#workbook-concept" id="workbook-concept"></a>

Workbooks allow you to view code results and documentation immediately within the code flow.

By hiding the actual code, you can change the view of the workbook to a document that can be read by non-experts.

By hiding results and documents, you can view the pure code of a document.

To use the hardware resource efficiently, we provide a workbook editor directly within the platform.

Like most things in your data pod, the workbook editor is geared towards full automation.

> Other workbook environments such as [Jupyter](https://jupyter.org/) or [Zeppelin](https://zeppelin.apache.org/) can also be used as an alternative to the data pod workbooks. This can be done via our [Direct Access](https://docs.record-evolution.de/#/en/Repods/monitor?id=web-api-access) interface. Using these workbooks, however, means that you may have to provide additional compute and storage resources. Also, you may have to take network bandwidth into account when shipping data from your data pod to your workbook environment.

### [Create or edit a workbook](https://docs.record-evolution.de/#/en/Repods/workbooks?id=create-or-edit-a-workbook) <a href="#create-or-edit-a-workbook" id="create-or-edit-a-workbook"></a>

Go to the *Analysis* panel to create new workbooks or edit existing ones.

To create a workbook, hit the *Workbook* button:

![](https://docs.record-evolution.de/en/Repods/media/workbooks/workbook-button.png)

To edit a workbook, click on one of the existing workbook cards within the *Results* area.

Either way, you are redirected to the workbook editor of your data pod.

The workbook editor consists of several panels and control elements. The workbook is assembled by stacking *workbook cards*. By using the insert card buttons as shown below, you can insert new cards into the editor.

As you see on the screenshot, you have a markdown card, a Python card, and a PostgreSQL card:

![](https://docs.record-evolution.de/en/Repods/media/workbooks/workbook-cards.png)

Click on the button in the upper right-hand corner to display the general workbook settings:

![](https://docs.record-evolution.de/en/Repods/media/workbooks/workbook-menu.png)

From here, you can hide or unhide the code, restart or stop the Python kernels, execute the card, rename and/or delete your workbooks. You also get an overview of some useful keyboard shortcuts.

Every change you make anywhere in the workbook is automatically saved.

The following sections describe the different types of cards within the workbook in more detail.

#### [PostgreSQL code card](https://docs.record-evolution.de/#/en/Repods/workbooks?id=postgresql-code-card) <a href="#postgresql-code-card" id="postgresql-code-card"></a>

A PostgreSQL code card enables you to write native PostgreSQL `SELECT` statements.

Click on the PostgreSQL button to create a card:

![](https://docs.record-evolution.de/en/Repods/media/workbooks/postgresql-card.png)

Using the toolbar on the left-hand side, you can manage the aspects of this card.

The *Run* button allows you to execute your `SELECT` statement. During execution, the button turns into a red *Stop* button which you can select again if you choose to cancel the query execution.

![](https://docs.record-evolution.de/en/Repods/media/workbooks/postgres-card.png)

The result of the query is stored in a table in the database. The name of this table is displayed right in the result section in this card. If you want to do further processing, you can query this result in another workbook card.

![](https://docs.record-evolution.de/en/Repods/media/workbooks/sql-at-work.png)

If you automate a card, the card will be executed whenever one of the dependent tables of your `SELECT` statement gets refreshed data. This will keep the card results always up to date.

Since the results of a code card are stored in a regular table, you can use this data in your [infographics](https://docs.record-evolution.de/#/en/Repods/infographs) and access it through our web [API](https://docs.record-evolution.de/#/en/monitor?id=web-api-access) or our direct data pod access.

*Note: All code cards can be executed in parallel.*

#### [Markdown card](https://docs.record-evolution.de/#/en/Repods/workbooks?id=markdown-card) <a href="#markdown-card" id="markdown-card"></a>

The markdown card enables you to provide documentation snippets for your workbook using a simple markdown format. A quick intro to markdown can be found [here](https://en.wikipedia.org/wiki/Markdown).

Click on the Markdown button to create a card:

![](https://docs.record-evolution.de/en/Repods/media/workbooks/markdown-card.png)

To edit the text in a markdown card, click on the card to get the markdown code to edit. Once you click outside of the card, the card will be re-rendered:

[**Edit mode & rendered mode**](https://docs.record-evolution.de/#/en/Repods/workbooks?id=edit-mode-amp-rendered-mode)

![](https://docs.record-evolution.de/en/Repods/media/workbooks/markdown-modes.png)

#### [Python card (v1)](https://docs.record-evolution.de/#/en/Repods/workbooks?id=python-card-v1) <a href="#python-card-v1" id="python-card-v1"></a>

A Python card enables you to write native Python code.

Click on the Python button to create a card:

![](https://docs.record-evolution.de/en/Repods/media/workbooks/python-card.png)

Your card will look like this:

![](https://docs.record-evolution.de/en/Repods/media/workbooks/start-python-card.png)

Here you can also use the built-in functions to create a table from a DataFrame, remove a table, retrieve a DataFrame from a table, display the table in the grid output and the visual data in the graph output.

Use the *Run* button at the top or cmd+E (keyboard shortcut) to execute the Python code.

During execution, you can always click on the *Stop* button to abort the code execution.

&#x20;

![](https://docs.record-evolution.de/en/Repods/media/workbooks/python-table.png)

![](https://docs.record-evolution.de/en/Repods/media/workbooks/python-at-work.png)

*The Python card (v1) comes with pre-installed Python libraries. The Python card (v2) will support the installation of additional libraries using pip.*

#### [Built-in functions](https://docs.record-evolution.de/#/en/Repods/workbooks?id=built-in-functions) <a href="#built-in-functions" id="built-in-functions"></a>

[**putTable (data\_frame , table\_name)**](https://docs.record-evolution.de/#/en/Repods/workbooks?id=puttable-data_frame-table_name)

Creates a PostgreSQL table from a DataFrame (if a table already exists, it is replaced).

**Parameters**

| Name        | Required | Type      |
| ----------- | -------- | --------- |
| data\_frame | yes      | DataFrame |
| table\_name | yes      | String    |

**Returns: table\_name**

Note that a table\_name is always appended with **wkb\_**. So if the table\_name is **emp\_data**, the actual table will be saved as **wkb\_emp\_data**.

**Example**

![](https://docs.record-evolution.de/en/Repods/media/workbooks/put-table.jpg)

[**getTable (table\_name)**](https://docs.record-evolution.de/#/en/Repods/workbooks?id=gettable-table_name)

Returns a Postgres table into a DataFrame.

**Parameters**

| Name        | Required | Type   |
| ----------- | -------- | ------ |
| table\_name | yes      | String |

**Returns: DataFrame**

**Example**

![](https://docs.record-evolution.de/en/Repods/media/workbooks/get-table.jpg)

[**dropTable (table\_name)**](https://docs.record-evolution.de/#/en/Repods/workbooks?id=droptable-table_name)

Drops the table created by the putTable function.

**Parameters**

| Name        | Required | Type   |
| ----------- | -------- | ------ |
| table\_name | yes      | String |

**Returns: String Message**

**Example**

![](https://docs.record-evolution.de/en/Repods/media/workbooks/drop-table.jpg)

[**showTable (table\_name)**](https://docs.record-evolution.de/#/en/Repods/workbooks?id=showtable-table_name)

Displays the table in the grid output.

**Parameters**

| Name        | Required | Type   |
| ----------- | -------- | ------ |
| table\_name | yes      | String |

**Returns: table\_name**

**Example**

![](https://docs.record-evolution.de/en/Repods/media/workbooks/pandas-dataframe.jpg)

[**showDataFrame (data\_frame , table\_name)**](https://docs.record-evolution.de/#/en/Repods/workbooks?id=showdataframe-data_frame-table_name)

Internally calls the putTable and the getTable functions.

**Parameters**

| Name        | Required | Type      |
| ----------- | -------- | --------- |
| data\_frame | yes      | DataFrame |
| table\_name | yes      | String    |

**Returns: DataFame**

**Example**

![](https://docs.record-evolution.de/en/Repods/media/workbooks/show-data-frame.jpg)

#### [Data visualization](https://docs.record-evolution.de/#/en/Repods/workbooks?id=data-visualization) <a href="#data-visualization" id="data-visualization"></a>

For data visualization, you can use libraries like matplotlib or seaborn. As usual, calling the function *plt.show()* will render the plot in the return window below the code.

* **Example Matplotlib**

![](https://docs.record-evolution.de/en/Repods/media/workbooks/matplotlib.jpg)

* **Example Seaborn**

![](https://docs.record-evolution.de/en/Repods/media/workbooks/seaborn.png)

#### [Supported Python libraries](https://docs.record-evolution.de/#/en/Repods/workbooks?id=supported-python-libraries) <a href="#supported-python-libraries" id="supported-python-libraries"></a>

**Stats and Analysis:** Numpy, Pandas, SciPY

**Machine Learning:** TensorFlow, Lifelines, scikit-learn, xgboost, lightgbm

**Data Visualization:** Seaborn, Matplotlib, Networkx

***

Once you have explored the chapter on workbooks, you can check out the other *Results* entities: [infographics](https://docs.record-evolution.de/#/en/Repods/infographs).

If you have any questions at this point or if you encounter any issues, do not hesitate to get in touch with our [support team](https://www.record-evolution.de/en/contact/).
