Spaces:
Sleeping
Sleeping
File size: 2,679 Bytes
5780425 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
{
"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
}
|