{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "f7a8a4a6", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "from matplotlib import pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "id": "af5151e2", "metadata": {}, "outputs": [], "source": [ "import mercury as mr" ] }, { "cell_type": "code", "execution_count": null, "id": "5a9fc098", "metadata": {}, "outputs": [], "source": [ "# control app with App class\n", "app = mr.App(title=\"DataFrame & Plots 🚀\", description=\"Showcase of Mercury Widgets\", show_code = False)" ] }, { "cell_type": "markdown", "id": "5ca6e6ea", "metadata": {}, "source": [ "# DataFrame and Plots 🎲📊\n", "\n", "Share your notebooks with everyone thanks to Mercury framework.\n", "\n", "Please change number of samples and number of features in the left side bar. Notebook will be recomputed after widget change." ] }, { "cell_type": "code", "execution_count": null, "id": "8182572d", "metadata": {}, "outputs": [], "source": [ "samples = mr.Slider(label=\"Number of samples\", min=50, max=100, value=75)\n", "features = mr.Select(label=\"Number of features\", choices=[\"5\", \"10\", \"15\"], value=\"10\")" ] }, { "cell_type": "code", "execution_count": null, "id": "efc441f6", "metadata": {}, "outputs": [], "source": [ "data = {}\n", "for i in range(int(features.value)):\n", " data[f\"Feature {i}\"] = np.random.rand(samples.value)\n", "df = pd.DataFrame(data)" ] }, { "cell_type": "markdown", "id": "eba6526e", "metadata": {}, "source": [ "## Random data 🎲" ] }, { "cell_type": "code", "execution_count": null, "id": "638de41f", "metadata": {}, "outputs": [], "source": [ "df" ] }, { "cell_type": "markdown", "id": "cef87336", "metadata": {}, "source": [ "## Scatter plot 📈" ] }, { "cell_type": "code", "execution_count": null, "id": "03ab6214", "metadata": {}, "outputs": [], "source": [ "_ = plt.plot(df[\"Feature 1\"], df[\"Feature 2\"], '*')" ] }, { "cell_type": "markdown", "id": "e42d394b", "metadata": {}, "source": [ "## Random data histogram 📊" ] }, { "cell_type": "code", "execution_count": null, "id": "6a88f486", "metadata": {}, "outputs": [], "source": [ "_ = plt.hist(df[\"Feature 1\"], bins=40)" ] } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 5 }