{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "2b02a8cc-cea0-479c-8e76-f60339d1b63d", "metadata": {}, "outputs": [ { "data": { "application/mercury+json": "{\n \"widget\": \"File\",\n \"max_file_size\": \"100MB\",\n \"label\": \"File upload\",\n \"model_id\": \"cabb68a84dd94439bbd6a77cf831a47f\",\n \"code_uid\": \"File.0.50.74.4-randc3c2ef99\",\n \"disabled\": false,\n \"hidden\": false\n}", "application/vnd.jupyter.widget-view+json": { "model_id": "cabb68a84dd94439bbd6a77cf831a47f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "mercury.File" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import mercury as mr\n", " \n", "# add file upload widget\n", "my_file = mr.File(label=\"File upload\", max_file_size=\"100MB\")" ] }, { "cell_type": "code", "execution_count": 2, "id": "3ba380e2-9503-45aa-8419-456bea19bd98", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(my_file.filepath or \"https://raw.githubusercontent.com/pandas-dev/pandas/refs/heads/main/pandas/tests/io/data/csv/iris.csv\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "dd4cc720-da9e-4118-9a39-d13634b4d78f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | SepalLength | \n", "SepalWidth | \n", "PetalLength | \n", "PetalWidth | \n", "Name | \n", "
---|---|---|---|---|---|
0 | \n", "5.1 | \n", "3.5 | \n", "1.4 | \n", "0.2 | \n", "Iris-setosa | \n", "
1 | \n", "4.9 | \n", "3.0 | \n", "1.4 | \n", "0.2 | \n", "Iris-setosa | \n", "
2 | \n", "4.7 | \n", "3.2 | \n", "1.3 | \n", "0.2 | \n", "Iris-setosa | \n", "
3 | \n", "4.6 | \n", "3.1 | \n", "1.5 | \n", "0.2 | \n", "Iris-setosa | \n", "
4 | \n", "5.0 | \n", "3.6 | \n", "1.4 | \n", "0.2 | \n", "Iris-setosa | \n", "
\n", " Create a plot in Python with matplotlib package.\n", "\n", "Input data:\n", "\n", "\n", "```python\n", "# pandas DataFrame\n", "'''\n", " SepalLength SepalWidth PetalLength PetalWidth Name\n", "0 5.1 3.5 1.4 0.2 Iris-setosa\n", "1 4.9 3.0 1.4 0.2 Iris-setosa\n", "2 4.7 3.2 1.3 0.2 Iris-setosa\n", "3 4.6 3.1 1.5 0.2 Iris-setosa\n", "4 5.0 3.6 1.4 0.2 Iris-setosa\n", "'''\n", "# DataFrame columns\n", "'''\n", "['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth', 'Name']\n", "'''\n", "\n", "# pandas data frame variable is df\n", "```\n", " \n", "\n", "\n", "Plot should contain: make a scatter plot\n", "\n", "Initial python code to be updated \n", "\n", "```python\n", "# TODO import required dependencies\n", "# TODO Provide the plot\n", "```\n", "\n", "Output only Python code.\n", "\n", "\n", "
\n", " ```python\n", "import matplotlib.pyplot as plt\n", "\n", "# Scatter plot\n", "plt.figure(figsize=(8, 6))\n", "plt.scatter(df['SepalLength'], df['SepalWidth'], label='Sepal', color='blue')\n", "plt.scatter(df['PetalLength'], df['PetalWidth'], label='Petal', color='green')\n", "plt.xlabel('Length')\n", "plt.ylabel('Width')\n", "plt.title('Sepal and Petal Measurements')\n", "plt.legend()\n", "plt.show()\n", "```\n", "\n", "