File size: 636 Bytes
23ab98a |
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 |
"""
A file that contains some helpers functions
"""
from typing import IO
import pandas as pd
import plotly.express as px
from plotly.graph_objs._figure import Figure
def load_data(file: IO) -> tuple[str
, str]:
global df
df = pd.read_csv(file.name)
return df.head().to_html(), f"Rows: {df.shape[0]}, Cols: {df.shape[1]}"
def show_summary() -> str:
if df is None:
return "Please upload a dataset first."
return df.describe().to_html()
def plot_column(colname: str) -> Figure | str:
if df is None:
return "Please upload a dataset first."
fig = px.histogram(df, x=colname)
return fig |