diff --git a/dashboard with outputs b/dashboard with outputs new file mode 100644 index 0000000..3f4f7df --- /dev/null +++ b/dashboard with outputs @@ -0,0 +1,60 @@ +import dash +import plotly.express as px +import pandas as pd + +# Data Exploration with Pandas (python) +# ----------------------------------------------------------------- + +df = pd.read_csv("reviews.csv") + +print(df[:5]) +print(df.iloc[:5, [2,3,5,10]]) +print(df.Genre.nunique()) +print(df.Genre.unique()) +print(sorted(df.Year.unique())) + +# Data Visualization (Python) +# ----------------------------------------------------------------- + +fig_pie = px.pie(data_frame=df, names='Genre', values='a') // +fig_pie = px.pie(data_frame=df, names='Genre', values='b') // +fig_pie.show() + +fig_bar = px.bar(data_frame=df, x='Genre', y='a') +fig_bar.show() + +fig_hist = px.histogram(data_frame=df, x='Year', y='a') +fig_hist.show() + +# Interactive Graphs with Dash +# ----------------------------------------------------------------- + +import dash_core_components as dcc +import dash_html_components as html +from dash.dependencies import Output, Input + +app = dash.Dash(__name__) + +app.layout=html.Div([ + html.H1("Graph Analysis with Charming Data"), + dcc.Dropdown(id='genre-choice', + options=[{'label':x, 'value':x} + for x in sorted(df.Genre.unique())], + value='Action' + ), + dcc.Graph(id='my-graph', + figure={}), +]) +@app.callback( + Output(component_id='my-graph', component_property='figure'), + Input(component_id='genre-choice', component_property='value') +) +def interactive_graphs(value_genre): + print(value_genre) + dff = df[df.Genre==value_genre] + fig = px.bar(data_frame=dff, x='Year', y='Japan Sales') + return fig + + +if __name__=='__main__': + app.run_server()