Datalore 2025.1 Help

Quick start tutorial

What is this topic about?

In this tutorial, you will prepare a short report on shopping trends based on your analysis of a .csv file with related data. You will learn how to perform the following basic tasks in Datalore:

  • Create your own workspace

  • Create a notebook

  • Connect data

  • Query and analyze your data

  • Build charts from your data

  • Add interactivity to your content

  • Share your results

Along the way, you will try some of Datalore's most powerful tools designed to improve your overall data analysis and code editing experience.

First steps

To get started, all you need to do is log into Datalore. You will find yourself on the Home page, in the default Private workspace, which is automatically created for every user after they log in for the first time.

Private workspace, Notebooks menu

You begin by creating your first own workspace. Own workspaces can be shared with other Datalore users, which is their main advantage over the 'unsharable' Private workspace.

The second step is creating a notebook where you will try most of Datalore's key features and tools.

Create your first workspace

  1. In the lower left corner of the Home page, click the New workspace button. This will open the New workspace dialog.

  2. In this dialog, provide a title for your new workspace and click the Create workspace.

Result

You are still on the Home page, but inside the newly created My First Workspace. In that workspace, you are at the moment in the Notebooks section, and it's empty for now. Your next step is adding a notebook here.

Your first workspace, Notebooks sections

Find more details about workspaces in this topic.

Create a notebook

  1. In the upper right corner of the screen, click the New notebook button.

  2. For now, all you need to do is provide a title for your notebook in the respective text field and click the Create notebook button at the bottom of the dialog.

    New notebook dialog

Result

You created a Python language notebook, which is automatically opened in the editor. For now, the notebook contains only one code cell, which is empty.

New notebook opened in the editor

Before your start editing your notebook

Make sure you complete each of the provided procedures in order to get the expected final result of this tutorial.

A few considerations

  • Main menu

    Use the Main menu at the top of the screen to manage your notebook and customize editor settings. For example, you can choose a dark mode by selecting View | Dark mode. Also, you will be instructed to run the notebook (all of its cells). You can do it by selecting Run | Run all.

  • Shortcuts

    In the procedures below, we provide UI-based instructions. However, for all described actions, you can use shortcuts. The full list can be found at Main menu | Help | Shortcuts. You can also open it by pressing Shift+F1.

  • Coding

    We provide code examples for the instructions below for you to copy and paste into your notebook. However, you can code everything yourself and test how Datalore helps you along the way with its code assistance features. Find more details in this topic.

Connect and access your data

The next step is attaching a source of data to your new notebook and accessing that data in your code. As mentioned earlier, you'll be working with a .csv file containing shopping tend information.

Attach your data file to the notebook

The easiest way to attach a data file to your notebook is to drag it directly into the notebook editor.

  1. Download the sample .csv file.

  2. Drag the downloaded file into your notebook.

  3. Make sure the file is attached to the notebook:

    1. Open the Attached data tool from the left-hand side of the editor.

    2. Find the shopping_trends.csv file on the Files tab of Attached data.

    Your dataset file in Attached data

Result

Your .csv file is attached to the notebook and can be accessed from code.

Pull data from the attached file

After your file is attached to the notebook, you can read its data and save it to a DataFrame for further analysis.

  1. Paste the code from the example below into the cell that you have in the editor.

    import pandas as pd my_table = pd.read_csv('shopping_trends.csv') my_table
  2. Execute the entered code by clicking the run icon in the upper left corner of the cell.

Result

You should get the following output for the executed code:

DataFrame from your attached file

The table comes with a number of interactivity features. Find more details in this topic.

Try an SQL cell

Datalore provide a special type of cells to retrieve data from attached sources using native SQL statements. SQL cells are particularly useful when working with database connections, but they work just as well for individual data files like the one you attached a few steps ago.

  1. Add an SQL cell to your notebook: click More under your first cell and select SQL.

    Adding an SQL cell
  2. In the added SQL cell:

    1. Expand the list of data source types and select Dataframes.

      Selecting a data source for SQL statement
    2. Enter the following SQL statement to pull data from your file:

      select * from shopping_trends.csv
    3. Run this SQL cell.

Result

You will get a DataFrame that is identical to the one you produced using Python in the previous step.

Provide your code with rich text

Make your project comprehensive and transparent by adding rich text to your code. This is where Datalore's Markdown cells come in handy.

Add a Markdown cell

  1. Under the first cell click More and select Markdown.

  2. In this new cell, provide a Markdown text that describes to your future notebook viewers what you want to do here. Try the input below:

    # Shopping trends analysis, experiment This experimental notebook analyzes shopping trends data and focuses on the following: <ul> <li>Preferred items</li> <li>Preferred payment methods</li> <li>Item distribution (by category, state, and season)</li></ul>
  3. Run the code. You will see the following:

    Your first Markdown cell

Result

You learned how to add rich text to your work in the notebook using Markdown cells. Feel free to add more cells where you find it appropriate.

Analyze your data

Now you can dig deeper into your data and visualize the findings.

Write your first code to start analyzing data

In this procedure, you will get a more specific data by ranking all items from most purchased to least purchased.

  1. Click Insert code cell under your last cell.

  2. In the new code cell, paste the following code:

    item_counts = my_table['Item Purchased'].value_counts().reset_index() item_counts.columns = ['Item', 'Total count'] item_counts
  3. Run the code in the cell. You'll get a DataFrame like this:

    New DataFrame after data analysis

Result

You get a new DataFrame with the results of your Python-driven analysis of the attached dataset.

DataFrame from SQL statement

Visualize your data without coding

In this procedure, you will learn how to visualize your data using different types of charts and export them as code.

  1. In the cell with your DataFrame from the previous procedure, switch to the Visualize tab. You will get a point chart based on your DataFrame content.

    Quick visualization of your DataFrame
  2. Point chart is the default setting. Change the type of the plot on the left side of the tab to try other options. For example, this is how a bar chart looks for this table.

    Bar chart from the same DataFrame
  3. This automatically built chart is not part of your code and therefore cannot be saved or shared as part of the notebook. However, you can export it as code. This will allow you to edit the chart programmatically or share it together with the rest of the notebook.

    Click export to code cell on the left side of the tab.

  4. This will add a cell to your notebook with a Python code that generates the selected chart. Now, this chart is part of the notebook code and can be edited or shared with the rest of the content. Run the cell to see the result.

    Bar chart from generated code

Result

You added a new Python cell that builds a chart for your dataset without writing any code manually.

Empower your coding with AI

In this part of the tutorial, you will learn how to use the AI functionality of Datalore to expand your coding abilities and edit your notebook faster.

Let's take a look at payment method distribution according to our data and build a pie chart for it. Pie charts are not available on the Visualize tab of Datalore code cells, meaning you need to provide your own code to build that kind of chart. That's where you might want to use the Ask AI tool available in all Datalore code cells.

Build a pie chart using AI support

  1. Add a new code cell to your notebook (B shortcut).

  2. On the toolbar of the cell, click the Ask AI icon. A prompt box will appear in the cell.

    Ask AI in a code cell
  3. Enter the prompt in the image below and click the Generate icon.

    Providing a prompt for Ask AI
  4. In the Review of generated prompt dialog, you can select which parts of the notebook will be sent for analysis for AI to generate a code suggestion. For now, just click the Submit button (for all notebook content to be analyzed).

    Reviewing prompt
  5. Soon you can see a code suggestion generated by AI. Click Accept and run to add the code to the cell and run it as-is.

    Accepting and running AI-generated code

Result

You used Datalore's native AI assistant to further analyze your data and build a pie chart based on your findings. Now, you know how to work with code cells without writing any code yourself.

Pie chart built with the use of Datalore's Ask AI tool

Add interactivity to your notebook

With massive datasets, there's a natural need to be able to select what data you want to see in the output, and how you want to see it. And of course, it is important that you do not have to change the code every time you want to tweak data presentation in your notebook.

Datalore solves this problem by helping you make your notebooks interactive. You add controls like dropdowns, sliders, or checkboxes to enable viewers of your notebook to change data presentations in a few clicks.

In this par of the tutorial, you will build two charts that will be updated using a dropdown control. The original dataset covers data across all states of the USA. With this dropdown, you will only view data for the states you select.

Add a dropdown control to filter your data

Begin by adding and setting up a dropdown control. In a nutshell, this dropdown control will draw values from the Location column to allow you to choose from all 50 states presented in the original table.

  1. First, create an array that will include all values (state names) from the Location column. Add a code cell and paste the following code:

    import numpy as np states = list(set(my_table.Location.values)) states = np.array(states) states = np.sort(states) states

    Now, you have an array to feed values to your future dropdown.

  2. Add a dropdown cell: click More and select Dropdown.

    This will add a new cell to your notebook and open the Dropdown dialog

  3. Configure your dropdown control:

    • Provide a label for the control. It should be something meaningful because this is the dropdown name that will be displayed in the notebook.

    • In the Variable field, provide a name for the variable that will store the selections made with this dropdown. In our case, that's the names of the states. This variable will be used in the analysis of your data, and it is that variable that will filter the data.

      It is important that you call this variable state. This name will be used in the next procedure.

    • Switch to the Dynamic tab. This is required to select a list variable that will feed the values that your dropdown will provide as selections.

      Expand the list and select states, which is the array of state names you created in the previous procedure.

    • Select the Multiselect checkbox to enable selecting more than one state name from the dropdown.

    • Click the Apply button to close the dialog.

      Dropdown dialog
  4. The dropdown cell that you added is now updated and can be used to select the respective values. Select the first two states from the list.

    Expanded dropdown

Result

You created a dropdown that allows to select values from one of your original table's columns. You will use this control to filter your dataset interactively without changing the code every time you want to view your data differently.

Apply interactively set values to your code

In this procedure, you will create two charts where source data is filtered by the selections of your dropdown.

The charts will display the following analysis results for any number of selected states:

  • Total purchases distributed over categories

  • Total purchases distributed over seasons

  1. First, filter the original DataFrame by the states that will be selected using your dropdown. You will do this by using the state variable that contains values selected with your dropdown.

    Add a new code cell and paste the code below.

    filtered_table_by_state = my_table[my_table['Location'].isin(state)]

    Now, you have the filtered_table_by_state DataFrame with data for the selected states only. That's the DataFrame you will be using to build the two charts.

  2. For your first chart, count purchases in each category and compare them in the selected states:

    1. Add another code cell.

    2. Paste the code below.

      grouped_state_items = filtered_table_by_state.groupby(['Category', 'Location'])['Item Purchased'].count().reset_index() grouped_state_items.columns = ['Category', 'Location', 'Total of purchases'] import seaborn as sns plt.figure(figsize=(12, 6)) sns.barplot(x='Category', y='Total of purchases', hue="Location", data=grouped_state_items) plt.title('Categorized total of purchases (by state)') plt.legend(loc='upper right') plt.show()
    3. Select Main Menu | Run | Run all to execute the entire notebook. This is required to make sure the last pieces of code use the values based on your earlier selection of 'Alaska' and 'Alabama'.

      You should have the following result.

      Bar chart with results filtered by dropdown selections
  3. Compare purchases in the selected states by season:

    1. Add one more code cell and paste the following code:

      total_items = filtered_table_by_state.groupby(['Season', 'Location'])['Item Purchased'].count().reset_index() unique_locations = filtered_table_by_state['Location'].unique() for location in unique_locations: data = total_items[total_items['Location'] == location] plt.figure(figsize=(10, 6)) plt.pie(data['Item Purchased'], labels=data['Season'], autopct='%1.1f%%') plt.title('Season distribution of purchases: ' + location) plt.show()
    2. Run the notebook one more time to view the results. For the same selection of states, 'Alaska' and 'Alabama', you should have this:

      Season distribution of purchases pie charts
  4. Make sure the interactivity works:

    1. Select different states from the dropdown.

    2. Run the notebook again.

    The outputs should have updated charts with data for the newly selected locations.

Result

You produced a few more charts, which are updated interactively using the dropdown created earlier.

This is made possible through the use of a variable that stores results of the last interactions with the dropdown.

This allows you to have data presentations that can be changed without editing your code in the input.

Share your result

Let's suppose that for the time being your part of analysis work on this project is done, and you want to share your notebook with your team members. With collaboration as one of its top priorities, Datalore provides a number of options for you to choose how exactly you want to do it.

In the next procedure, you share this notebook by granting edit access to any other Datalore users with a shareable link.

  1. In the editor, click the share icon in the upper right corner of the editor. This will open the Share [notebook_name] dialog.

  2. Click No access link to expand the list of access types and select Edit access link.

    Selecting access type for a shared notebook

    The link is created. You can copy it or click it to open the notebook with editing rights in a new browser tab.

    Edit access link created

Result

You shared your notebook by granting edit access to anyone who has the generated link.

You can track actions by other contributors in real-time: avatars of other people currently working on your notebook will be visible next to your own. Collaborators can also leave comments (more details here).

All changes made by other editors will be saved to your notebook. You can track all these changes and roll back to earlier versions of the notebook using the History tool (Main menu | Tools).

Publish you notebook

The final part of this tutorial is presenting your notebook as an interactive report. You will publish your notebook as a standalone web page that viewers can interact with to update the charts you prepared. The key difference between a shared notebook and a published notebook is that the latter option is aimed at the audience that is only interested in outputs. Report viewers are not expected to look into the code or change it. While notebooks are shared for further collaboration on them, they are published to make the results of data analysis available to a wider audience.

Build a report

This procedure explains how to use a tool called Report builder to design a report based on your notebook.

  1. Click the Build report button in the upper right corner of the editor. You will see something like this:

    Report builder tool

    In short, the tool works like a canvas where you place and arrange content of your notebook cells. To the left of the canvas, you have a cell list, where you select what inputs and outputs you want to place on the canvas.

    The canvas also serves as a mockup of your future report so you know what your notebook looks like when published.

    The canvas already has some content placed on it, but you need to make sure that's exactly what you want to show. For example, you don't want any tables included in the report. You just want to present the charts. Also, no code inputs are expected to be shown in this report.

  2. In the Cell list menu, select the following content:

    • Markdown cell output with the introductory text (added here)

    • Code cell output with the exported bar chart (added here)

    • Code cell output with the pie chart you built using AI (added here)

    • The dropdown for selecting states (added here)

    • Code cell outputs with charts updated interactively (added here)

    Selecting content for report
  3. Now, with the required content on the canvas, re-arrange some of its segments to optimize the look of your future report:

    1. Reduce the cell with the bar chart by dragging the resize handles (displayed when hovering over the cell). This will free up a lot of area on the canvas.

    2. Click the Arrange button in the upper right corner of the Report builder to re-arrange the content and remove the unoccupied area.

    3. Resize the cell with the pie chart (Distribution of Payment Methods) to remove the unoccupied area.

      Charts after resizing
    4. Drag the pie chart to the right of the bar chart.

      Charts grouped together
    5. Click the Arrange button again to 'pull up' the rest of the content closer to the resized cells.

Result

Your notebook is now ready to be published as a report. This report will feature the content that you specifically selected for publishing.

Learn more about working in the Report builder in this topic.

Publish your notebook as an interactive report

In this procedure, you publish the report that you built in the previous procedure. This will be an interactive report, which will allow its users to change data views using the dropdown control you added earlier in this tutorial. It is assumed that you're still in the Report builder and have completed the steps described here.

  1. Click the Publish report button under the Cell list. This will open the Publish [report_name] dialog.

  2. In the dialog:

    1. Expand the list under Report type and select Interactive report.

    2. Select the Reactive mode checkbox to ensure interactivity.

      Notebook publishing dialog
    3. Click the Publish button.

    You will get a confirmation window.

    Published report confirmation window
  3. In the Confirmation window, click the Open report button.

Result

You have published your notebook as an interactive report. Try the dropdown control to make sure a new selection of values will change the data views.

Interactive report with a dropdown

Keywords

getting started, first notebook, demonstration, demo notebook, how to begin, quickstart, how to use Datalore, Datalore guide, basic procedures

Last modified: 20 December 2024