mirror of
https://github.com/bluxmit/alnoda-workspaces.git
synced 2024-09-28 23:41:30 +12:00
179 lines
No EOL
4.8 KiB
Text
179 lines
No EOL
4.8 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"id": "5a3ab9ad-eec7-40e2-ab8f-08c7a4fda7d0",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import altair as alt\n",
|
|
"import datapane as dp\n",
|
|
"import pandas as pd"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"id": "1c5e412d-98c9-4ec4-8d0c-3f3524380552",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Load csv file into Pandas data frame\n",
|
|
"df = pd.read_csv('cars.csv') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"id": "94757a60-8bfc-4257-9bc6-6236a78e9da5",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"plot1 = alt.Chart(df).mark_circle(size=60).encode(\n",
|
|
" x='Horsepower',\n",
|
|
" y='Miles_per_Gallon',\n",
|
|
" color='Origin',\n",
|
|
" tooltip=['Name', 'Origin', 'Horsepower', 'Miles_per_Gallon']\n",
|
|
").interactive()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "91c37b5b-5b54-4a53-af0e-cde258f4eb9b",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Datapane report: Example 1\n",
|
|
"Text, plot and data table"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"id": "b7a8594e-6727-441b-bfed-e545dd95af49",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/markdown": [
|
|
"Report saved to .//home/static-server/Cars-report.html. To upload and share your report, create a free Datapane account by running `!datapane signup`."
|
|
],
|
|
"text/plain": [
|
|
"<IPython.core.display.Markdown object>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"dp.Report(\n",
|
|
" dp.Text(\"## Cars report!\"),\n",
|
|
" dp.Plot(plot1),\n",
|
|
" dp.DataTable(df)\n",
|
|
").save(path=\"/home/static-server/Cars-report.html\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "e7692543-6b7a-47a8-8423-6454c1f2d906",
|
|
"metadata": {},
|
|
"source": [
|
|
"Open report with Static File Server"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "7e1f7f0c-6b29-45b3-ac17-093cd889b862",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Datapane report: example 2\n",
|
|
"add more examples: formula, number card, selector. Make 2 tabs"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"id": "e22a99fc-2f0c-426d-8466-debf8a6a3590",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/markdown": [
|
|
"Report saved to .//home/static-server/Cars-report-2.html. To upload and share your report, create a free Datapane account by running `!datapane signup`."
|
|
],
|
|
"text/plain": [
|
|
"<IPython.core.display.Markdown object>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"dp.Report(\n",
|
|
" dp.Page(title=\"Charts and analysis\",\n",
|
|
" blocks=[\n",
|
|
" dp.Formula(\"x^2 + y^2 = z^2\"),\n",
|
|
" dp.Group(\n",
|
|
" dp.BigNumber(\n",
|
|
" heading=\"Number of percentage points\",\n",
|
|
" value=\"84%\",\n",
|
|
" change=\"2%\",\n",
|
|
" is_upward_change=True\n",
|
|
" ),\n",
|
|
" dp.BigNumber(\n",
|
|
" heading=\"Simple Statistic\",\n",
|
|
" value=100\n",
|
|
" ), columns=2,\n",
|
|
" ),\n",
|
|
" dp.Select(blocks=[\n",
|
|
" dp.Plot(plot1, label=\"Plot\"),\n",
|
|
" dp.HTML('''<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/dQw4w9WgXcQ\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>''', label=\"Video\")\n",
|
|
" ]),\n",
|
|
" ]),\n",
|
|
" dp.Page(title=\"Dataset\", blocks=[\n",
|
|
" dp.DataTable(df)\n",
|
|
" ])\n",
|
|
").save(path=\"/home/static-server/Cars-report-2.html\", open=True)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "3a9b9f97-eae0-4d71-adb4-8070e76b0b65",
|
|
"metadata": {},
|
|
"source": [
|
|
"Open report with Static File Server"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "7f3f7485-ade2-422e-a126-9cc4f221aa88",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.8.10"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
} |