Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions dashboard with outputs
Original file line number Diff line number Diff line change
@@ -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()