Skip to content

PLOTLY_DATASET

Retrieve a pandas DataFrame from one of Plotly Express's built-in datasets. Params: dataset_key : str Returns: out : DataFrame
Python Code
from flojoy import flojoy, DataFrame
from plotly.express import data
from typing import Literal


@flojoy
def PLOTLY_DATASET(
    dataset_key: Literal[
        "wind",
        "iris",
        "carshare",
        "tips",
        "election",
        "experiment",
        "gapminder",
        "medals_long",
        "medals_wide",
        "stocks",
    ] = "wind",
) -> DataFrame:
    """Retrieve a pandas DataFrame from one of Plotly Express's built-in datasets.

    Parameters
    ----------
    dataset_key : str

    Returns
    -------
    DataFrame
    """

    df = getattr(data, dataset_key)()

    return DataFrame(df=df)

Find this Flojoy Block on GitHub

Example

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

The PLOTLY_DATASET app

The workflow of this app is described below:

PLOTLY_DATASET : This is a Plotly Dataset node. It takes one parameter dataset_key, the name of dataset to load from plotly sample datasets. In this case it is ‘wind’ which is default value of this parameter. It passing a DataFrame object of DataContainer class to the next node Table.

TABLE: This node creates a Plotly table visualization for a given input DataFrame object of DatacContainer class.

TERMINATE: This node terminating the current script run. The output of this node is same as its parent node.