Spaces:
Sleeping
Sleeping
File size: 2,555 Bytes
350cda1 e282b06 350cda1 efdf97d e282b06 350cda1 fed3d99 a740be5 e282b06 350cda1 4b273a0 efdf97d 4b273a0 efdf97d 9e3bbe8 e282b06 9e3bbe8 efdf97d e282b06 350cda1 efdf97d 9e3bbe8 efdf97d 9e3bbe8 efdf97d 9e3bbe8 efdf97d fed3d99 9e3bbe8 fed3d99 3e7782f fed3d99 9e3bbe8 fed3d99 9e3bbe8 a740be5 9e3bbe8 fed3d99 efdf97d fed3d99 efdf97d fed3d99 efdf97d fed3d99 |
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 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
# %% auto 0
__all__ = ['template', 'switch', 'url', 'file', 'bound_data', 'show_input_widget', 'get_data']
# %% app.ipynb 1
import panel as pn
import hvplot.pandas
import pandas as pd
import numpy as np
import io
import helpers.utils as utils
# %% app.ipynb 2
pn.extension(
)
template = pn.template.FastListTemplate(title="Dataset Analyser", site="Dashboard", main=[],
)
template.sidebar.append(pn.Column(
pn.pane.Markdown(
"""
# Welcome to the Interactive Data App
This app allows you to interact with the data in a number of ways.
"""
)
));
# %% app.ipynb 3
template.sidebar.append(pn.Column(
pn.pane.Markdown(
"""
## Load Data
You can load the data from a URL or upload a file.
"""
)
));
switch = pn.widgets.Switch(name="URL - FILE", value=False)
url = pn.widgets.TextAreaInput(name="url", placeholder="Enter the url of the dataset", value="https://raw.githubusercontent.com/holoviz/panel/main/examples/assets/occupancy.csv");
file = pn.widgets.FileInput(
accept=".csv", name="Upload a CSV file",
)
# %% app.ipynb 4
def show_input_widget(switch: pn.widgets.Switch):
if not switch:
return pn.Row(url);
else:
return pn.Row(file);
# %% app.ipynb 5
def get_data(switch: pn.widgets.Switch, url: pn.widgets.TextAreaInput, file: pn.widgets.FileInput):
df = None
if not switch:
df = pd.read_csv(url)
else:
if file is None:
return "No file selected"
df = pd.read_csv(io.BytesIO(file))
visualizations = utils.Visualizations(df, pn)
high_level_widget = visualizations.high_level_visualization()
shape_widget = visualizations.data_shape_visualization()
nature_widget = visualizations.nature_visualization()
distribution_widget = visualizations.distribution_visualization()
return pn.Column(
high_level_widget,
pn.Row(shape_widget,
nature_widget,
distribution_widget)
)
bound_data = pn.bind(get_data, switch=switch, url=url, file=file)
template.sidebar.append(pn.Column(
pn.Row(switch),
pn.Row(pn.bind(show_input_widget, switch)),
));
template.main.append(bound_data)
template.servable();
# %% app.ipynb 6
# | export
# %% app.ipynb 7
# dataset = None
# if file:
# dataset = pd.read_csv(file)
# else:
# dataset = pd.read_csv(url.value)
# pn.Row(dataset.head().hvplot().opts(width=800, height=400)).servable(target="main");
|