Onvo Documentation
APIs
Questions
Get:Get Questions by Dashboard

Get questions by dashboard

GET
/
api
/
questions

Authorizations

x-api-key
string
headerrequired

Response

200 - application/json

The response is of type object.

[
    {
        "id": "665b4c0a-4d50-48d6-9045-5e3ce2b4a503",
        "created_at": "2024-02-08T07:10:24.99291+00:00",
        "dashboard": "fd0b9d77-791d-4898-afa6-99800301d861",
        "query": "Which state gives me the highest orders?",
        "assumptions": [
            "",
            "1. Load the necessary columns from the 'Sample Orders' dataset to count the number of orders per state. We will need the 'Customer ID' and 'State' columns.",
            "2. Load the 'Customer ID' and 'State' columns from the 'Sample Customers' dataset to map each order to a state.",
            "3. Merge the two datasets on 'Customer ID' to associate each order with a state.",
            "4. Group the merged dataset by 'State' and count the number of orders for each state.",
            "5. Choose a bar chart as the visualization type since we are comparing the frequency of a categorical variable (state) and it is not specified by the user.",
            "6. Sort the data to have the state with the highest orders at the top.",
            "7. Create the chart.js object with the sorted data, setting the type to 'bar'.",
            "8. Set the responsive option to true and maintainAspectRatio to false.",
            "9. Add a title to the chart that describes the content, such as \"Number of Orders per State\".",
            "10. Set the plugins.datalabels.display option to false as the user did not ask to show the values in the chart.",
            "",
            ""
        ],
        "code": "import pandas as pd\ndef main():\n    # Load necessary columns from the datasets\n    customers_df = pd.read_csv('/tmp/6c06673a-8b53-4eba-a4a8-17e23daf0504.csv', usecols=['Customer ID', 'State'])\n    orders_df = pd.read_csv('/tmp/9f5cd772-aaff-460e-8e7a-03d21070b12c.csv', usecols=['Customer ID'])\n    # Merge datasets on 'Customer ID'\n    merged_df = pd.merge(orders_df, customers_df, on='Customer ID', how='left')\n    # Group by 'State' and count the number of orders\n    state_order_counts = merged_df.groupby('State').size().reset_index(name='Orders')\n    # Sort the states by the number of orders\n    state_order_counts_sorted = state_order_counts.sort_values(by='Orders', ascending=False)\n    # Create the chart.js object\n    chart = {\n        'type': 'bar',\n        'data': {\n            'labels': state_order_counts_sorted['State'].tolist(),\n            'datasets': [{\n                'label': 'Number of Orders',\n                'data': state_order_counts_sorted['Orders'].tolist(),\n                'backgroundColor': 'rgba(54, 162, 235, 0.2)',\n                'borderColor': 'rgba(54, 162, 235, 1)',\n                'borderWidth': 1\n            }]\n        },\n        'options': {\n            'responsive': True,\n            'maintainAspectRatio': False,\n            'plugins': {\n                'title': {\n                    'display': True,\n                    'text': 'Number of Orders per State'\n                },\n                'datalabels': {\n                    'display': False\n                }\n            },\n            'scales': {\n                'y': {\n                    'beginAtZero': True\n                }\n            }\n        }\n    }\n    return chart",
        "output": "The state that gives you the highest number of orders is **California**, with a total of **1998 orders**.",
        "embed_user": null,
        "account": null,
        "team": "ee5b08c6-5167-4425-bbc3-a746fe4a7ead",
        "cache": "{\"type\":\"bar\",\"data\":{\"labels\":[\"California\",\"New York\",\"Texas\",\"Pennsylvania\",\"Illinois\",\"Ohio\",\"Washington\",\"North Carolina\",\"Arizona\",\"Florida\",\"Colorado\",\"Michigan\",\"Georgia\",\"Virginia\",\"Indiana\",\"Minnesota\",\"Tennessee\",\"Kentucky\",\"Wisconsin\",\"Alabama\",\"New Jersey\",\"Massachusetts\",\"Delaware\",\"Louisiana\",\"Utah\",\"Connecticut\",\"Rhode Island\",\"Mississippi\",\"Missouri\",\"Oregon\",\"Iowa\",\"New Mexico\",\"Nebraska\",\"New Hampshire\",\"Maryland\",\"Arkansas\",\"South Dakota\",\"Oklahoma\",\"Kansas\",\"Nevada\",\"District of Columbia\"],\"datasets\":[{\"label\":\"Number of Orders\",\"data\":[1998,1110,917,641,574,480,460,343,301,290,283,220,201,182,167,167,167,149,144,127,123,114,93,85,80,74,64,61,60,60,45,41,32,28,24,21,16,16,13,12,11],\"backgroundColor\":\"rgba(54, 162, 235, 0.2)\",\"borderColor\":\"rgba(54, 162, 235, 1)\",\"borderWidth\":1}]},\"options\":{\"responsive\":true,\"maintainAspectRatio\":false,\"plugins\":{\"title\":{\"display\":true,\"text\":\"Number of Orders per State\"},\"datalabels\":{\"display\":false}},\"scales\":{\"y\":{\"beginAtZero\":true}}}}"
    },
    {
        "id": "7135ce6b-372e-4879-9b99-b818a73155d4",
        "created_at": "2024-02-08T07:10:24.992797+00:00",
        "dashboard": "fd0b9d77-791d-4898-afa6-99800301d861",
        "query": "How many orders do I have year over year?",
        "assumptions": [
            "",
            "1. Load the 'Order Date' column from the 'Sample Orders' dataset using pandas, as it contains the necessary information to calculate the number of orders year over year.",
            "2. Convert the 'Order Date' column to datetime format to extract the year from each date.",
            "3. Group the data by year and count the number of orders for each year.",
            "4. Create a bar chart using Chart.js configuration as it is the most appropriate chart type for showing the number of orders year over year.",
            "5. Set the x-axis to represent the years and the y-axis to represent the number of orders.",
            "6. Add a title to the chart to describe the content.",
            "7. Set the responsive option to true and maintainAspectRatio to false.",
            "8. Set the plugins.datalabels.display option to false as the user has not asked to show the values in the chart.",
            "9. Return the chart configuration as a dictionary.",
            "",
            ""
        ],
        "code": "import pandas as pd\ndef main():\n    # Load the 'Order Date' column from the 'Sample Orders' dataset\n    orders_df = pd.read_csv('/tmp/9f5cd772-aaff-460e-8e7a-03d21070b12c.csv', usecols=['Order Date'])\n    \n    # Convert 'Order Date' to datetime and extract the year\n    orders_df['Order Date'] = pd.to_datetime(orders_df['Order Date'], format='%Y-%m-%d')\n    orders_df['Year'] = orders_df['Order Date'].dt.year\n    \n    # Group by year and count the number of orders\n    orders_per_year = orders_df.groupby('Year').size()\n    \n    # Prepare the data for the bar chart\n    data = {\n        'labels': orders_per_year.index.astype(str).tolist(),\n        'datasets': [{\n            'label': 'Number of Orders',\n            'data': orders_per_year.tolist(),\n            'backgroundColor': 'rgba(54, 162, 235, 0.2)',\n            'borderColor': 'rgba(54, 162, 235, 1)',\n            'borderWidth': 1\n        }]\n    }\n    \n    # Chart configuration\n    chart_config = {\n        'type': 'bar',\n        'data': data,\n        'options': {\n            'responsive': True,\n            'maintainAspectRatio': False,\n            'plugins': {\n                'title': {\n                    'display': True,\n                    'text': 'Number of Orders Year Over Year'\n                },\n                'datalabels': {\n                    'display': False\n                }\n            },\n            'scales': {\n                'y': {\n                    'beginAtZero': True\n                }\n            }\n        }\n    }\n    \n    return chart_config",
        "output": "You have the following number of orders year over year:\n- **2015**: 1,993 orders\n- **2016**: 2,102 orders\n- **2017**: 2,587 orders\n- **2018**: 3,312 orders\nEach year, the number of orders has increased.",
        "embed_user": null,
        "account": null,
        "team": "ee5b08c6-5167-4425-bbc3-a746fe4a7ead",
        "cache": "{\"type\":\"bar\",\"data\":{\"labels\":[\"2015\",\"2016\",\"2017\",\"2018\"],\"datasets\":[{\"label\":\"Number of Orders\",\"data\":[1993,2102,2587,3312],\"backgroundColor\":\"rgba(54, 162, 235, 0.2)\",\"borderColor\":\"rgba(54, 162, 235, 1)\",\"borderWidth\":1}]},\"options\":{\"responsive\":true,\"maintainAspectRatio\":false,\"plugins\":{\"title\":{\"display\":true,\"text\":\"Number of Orders Year Over Year\"},\"datalabels\":{\"display\":false}},\"scales\":{\"y\":{\"beginAtZero\":true}}}}"
    },
    {
        "id": "d860060c-68e1-4c9d-bdbc-d84ca0337c5f",
        "created_at": "2024-02-08T07:11:36.573628+00:00",
        "dashboard": "fd0b9d77-791d-4898-afa6-99800301d861",
        "query": "What is my LTV in CAD?",
        "assumptions": [
            "",
            "1. Load the 'Sample Orders' dataset as it contains the 'Sales' and 'Profit' columns which are necessary to calculate the Lifetime Value (LTV) of a customer.",
            "2. Since the user has asked for LTV in CAD and the 'Sales' and 'Profit' are in USD, we will assume a conversion rate from USD to CAD. This conversion rate is not provided, so we will use a placeholder value that should be replaced with the actual conversion rate.",
            "3. Calculate the LTV for each customer by summing up the 'Sales' and 'Profit' for each 'Customer ID', then convert the total to CAD.",
            "4. Since LTV is a single metric, we will use a 'metric' type chart in the config.",
            "5. The data.datasets.data array will contain the single value of LTV in CAD.",
            "6. The datasets.label will be set to \"CAD\" as it is the unit for the metric.",
            "7. Set the responsive and maintainAspectRatio options as specified.",
            "8. Add a title to the chart that describes the metric being displayed.",
            "9. Set plugins.datalabels.display to false as per the instructions.",
            "",
            ""
        ],
        "code": "import pandas as pd\ndef main():\n    # Load the necessary columns from the 'Sample Orders' dataset\n    orders_df = pd.read_csv('/tmp/9f5cd772-aaff-460e-8e7a-03d21070b12c.csv', usecols=['Customer ID', 'Sales', 'Profit'])\n    \n    # Convert 'Sales' and 'Profit' to numerical values\n    orders_df['Sales'] = orders_df['Sales'].map(convertNum)\n    orders_df['Profit'] = orders_df['Profit'].map(convertNum)\n    \n    # Assume a conversion rate from USD to CAD (placeholder value, to be replaced with actual conversion rate)\n    usd_to_cad_conversion_rate = 1.25\n    \n    # Calculate LTV in CAD\n    ltv_cad = (orders_df['Sales'] + orders_df['Profit']).sum() * usd_to_cad_conversion_rate\n    \n    # Create the chart.js object as a dictionary\n    chart = {\n        'type': 'metric',\n        'data': {\n            'datasets': [{\n                'label': 'CAD',\n                'data': [ltv_cad]\n            }]\n        },\n        'options': {\n            'responsive': True,\n            'maintainAspectRatio': False,\n            'plugins': {\n                'title': {\n                    'text': 'Lifetime Value (LTV) in CAD'\n                },\n                'datalabels': {\n                    'display': False\n                }\n            }\n        }\n    }\n    \n    return chart",
        "output": "Your Lifetime Value (LTV) in CAD is **$3,229,497.35**.",
        "embed_user": "ee5b08c6-5167-4425-bbc3-a746fe4a7ead-5899f99d-a449-4bfa-8769-19c097aaf1f6",
        "account": "5899f99d-a449-4bfa-8769-19c097aaf1f6",
        "team": "ee5b08c6-5167-4425-bbc3-a746fe4a7ead",
        "cache": "{\"type\":\"metric\",\"data\":{\"datasets\":[{\"label\":\"CAD\",\"data\":[3229497.3525]}]},\"options\":{\"responsive\":true,\"maintainAspectRatio\":false,\"plugins\":{\"title\":{\"text\":\"Lifetime Value (LTV) in CAD\"},\"datalabels\":{\"display\":false}}}}"
    }
]