kandy 0.6.0 Help

Kandy in Datalore

Datalore is a collaborative data science platform designed to streamline insight delivery, facilitating more productive collaboration between data science and business teams. This platform is adept for tasks such as data collection, exploration, machine learning, interactive visualization, and reporting.

Datalore supports Python, Kotlin, Scala, and R notebooks without the need for preliminary setup, offering computational resources tailored to your requirements.

Getting Started with Datalore

  1. Open Datalore.

  2. Register if you don't already have an account.

  3. On the home page, click on the New Notebook button.

    New Notebook button

    You will be redirected to the New Notebook page where you can set the notebook's title, select a kernel, choose a computation mode, and configure various other settings.

  4. Select the Kotlin Kernel and click Create Notebook.

    New Notebook page
  5. In the notebook, execute the following cell to add the Kandy library:

%use kandy

You now have access to the Kandy library within your Kotlin Notebook in Datalore.

Plotting a Simple Example

Let's create data that will be used to construct the plot. This data will represent the average annual temperatures in various cities. When working in interactive notebooks, it is advisable to divide the data creation and plot construction into two separate cells. This approach ensures that extension properties are generated for our columns in the DataFrame, allowing us to reference them easily.

First, create a DataFrame containing data on the average temperatures in different cities as follows:

// Create a DataFrame with data on average temperatures in various cities val averageTemperature = dataFrameOf( "city" to listOf("New York", "London", "Berlin", "Yerevan", "Tokyo"), "average temperature" to listOf(12.5, 11.0, 9.6, 11.5, 16.0) )

Next, construct a simple plot using the data from the DataFrame:

// Construct a plot using the data from the DataFrame averageTemperature.plot { // Add bars to the plot // Each bar represents the average temperature in a city bars { x(city) // Set the cities' data on the X-axis y(`average temperature`) { // Set the temperatures' data on the Y-axis axis.name = "Average Temperature (°C)" // Assign a name to the Y-axis } } // Set the title of the plot layout.title = "Kandy Getting Started Example" }
Kandy Getting Started Example

This supplementary schema outlines the key elements of Kandy's DSL, providing a quick reference to assist you in building your visualizations.

For more examples, please see the Examples section.

Last modified: 13 May 2024