Spaces:
Sleeping
Sleeping
| # 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"); | |