<jupyter_start><jupyter_text>DASHboardquick, cheap, beautiful, healthy workshop  What is a dashboard?  Carriage dashboard![Carriage dashboard](images/carriagedashboard.jpg)> https://sla.talkbank.org/tours/carriagedashboard.jpg  Car dashboard![Car dashboard](images/cardashboard.jpg)> https://image.cpsimg.com/sites/carparts-mc/assets/classroom/images/dash_gauges.jpg  Business dashboard![Business dashboard](images/businessdashboard.png)> http://www.byteorigin.com/wp-content/uploads/2016/07/206531097.png  Why to build a dashboard?- Good overview on important data- No need to visit multiple places- Quick identification of problems - being able to react on time- Discovering insights from data- Ability to share results easily (reports)  How to build a dashboard?  Understand needs- Understand data    - Ask right questions    - KPIs (Key Performance Indicators)- Audience    - Strategical    - Analytical (lot of interaction)  Design- Make it simple    - Speak user's language    - Minimize distracitons    - Narrow down filters and metrics to the ones that will have impact    - Make every pixel count `data_ink_ratio = pixels_presenting_data / total_pixels`- Choose right visualizations    - For example: 3D pie charts for 2D data is just bad... Bar is much easier to compare- Make data actionable    - Provide enough context  Tools- Excel-like software- Custom webapp- Custom desktop widget- Many "out of the box solutions"- ...- Dash  More- https://en.wikipedia.org/wiki/Dashboard- https://en.wikipedia.org/wiki/Dashboard_(business)- https://www.youtube.com/watch?v=RtKDSfWFQIA  GapminderDashboard we are building Inspirationhttps://www.youtube.com/watch?v=hVimVzgtD6w Toolhttps://www.gapminder.org/tools/  Data for dashboard  Pandashttp://pandas.pydata.org/<jupyter_code>import pandas as pd
countries = pd.Series(['Argentina', 'Austria', 'Australia'])
countries
dataset = pd.DataFrame({
    'country': ['Argentina', 'Austria', 'Australia'],
    'population': [43e6, 8e6, 24e6],
})
dataset
dataset.info()
dataset.describe()
dataset.head(2)
dataset['population']
dataset[ ['population'] ]
dataset['population'].values
dataset['population'].tolist()<jupyter_output><empty_output><jupyter_text>...however many things in Python ecosystem consume Series as if you passed list/np.array. Casting happens underhood.<jupyter_code>dataset.loc[0]
dataset.loc[0, 'population']
country_indexed_dataset = dataset.set_index('country')
country_indexed_dataset
country_indexed_dataset.index
country_indexed_dataset.loc['Austria']<jupyter_output><empty_output><jupyter_text>Morehttps://github.com/Nozdi/first-steps-with-pandas-workshop  Data<jupyter_code>from gapminder.data import (
    get_config,
    load_data,
)
data = load_data()
data.keys()
data['Population density (per square km)'].head()
data['Population density (per square km)'].describe()
data['Population density (per square km)']['2000'].head()<jupyter_output><empty_output><jupyter_text>Bonus quizOn which continent is situated `Akrotiri and Dhekelia`?<jupyter_code>(
    data['Population density (per square km)']['2000']
    .dropna()
    .head(10)
)
X_AXIS = "Life expectancy"
Y_AXIS = "GDP per capita"

conf = get_config(data, x_axis=X_AXIS, y_axis=Y_AXIS)

conf
get_config?
conf.keys()<jupyter_output><empty_output><jupyter_text>Keys Cheatsheet- *countries* - countries that we are going to handle on dashboard- *years* - interesction of years available in x_df, y_df, z_df- *x_df* - DataFrame to be used for x dimension- *y_df* - DataFrame to be used for y dimension- *z_df* - DataFrame to be used for z dimension. We do not do 3D charts. Z dimension can be.. bubble size<jupyter_code>conf['y_df'].head()<jupyter_output><empty_output><jupyter_text>Exercises Get config for:    x - life expectancy    y - murder rate per 100000 ppl    and access life expectancy of Japanese people in 2000 from that config<jupyter_code># Here solution<jupyter_output><empty_output><jupyter_text>First graphsPlotly: https://plot.ly/python/getting-started/<jupyter_code>import plotly
import plotly.graph_objs as go
plotly.offline.plot({
    'data': [
        go.Bar(
#             x=['Australia', 'Austria'],
#             y=[24e6, 8e6]
        )
    ],
    'layout': {}
})
# We can do plots inline

plotly.offline.init_notebook_mode(connected=True)
plotly.offline.iplot({
    'data': [
        go.Bar(
            x=['Australia', 'Austria'],
            y=[24e6, 8e6]
        )
    ],
    'layout': {}
})
# Different GraphObjects can be mixed

plotly.offline.iplot({
    'data': [
        go.Bar(
            x=['Australia', 'Austria'],
            y=[24e6, 8e6]
        ),
        go.Scatter(
            x=['Argentina', 'Austria'],
            y=[43e6, 8e6]
        )
    ],
    'layout': {}
})
# How to style dot differently

plotly.offline.iplot({
    'data': [
        go.Scatter(
            x=['Argentina'],
            y=[43e6],
#             marker={
#                 'color': 'blue',
#                 'size': 100,
#             },
#             name='Argentina'
        ),
        go.Scatter(
            x=['Austria'],
            y=[8e6],
#             marker={
#                 'color': 'red',
#                 'size': 40,
#                 'opacity': 0.2,
#             },
#             name='Austria'
        )
    ],
    'layout': {
#         'showlegend': False
    }
})
# How to use DataFrame

plotly.offline.iplot({
    'data': [
        go.Scatter(
            x=conf['x_df']['2000'],
            y=conf['y_df']['2000'],
#             mode='markers'
        )
    ],
    'layout': {
#         'title': 'GDP per capita over life expectancy',
#         'xaxis': {
#             'title': 'Life expectancy',
#             'titlefont': {
#                 'size': 30
#             }
#         },
#         'width': 500
    }
})
# Index can be also used as data

plotly.offline.iplot({
    'data': [
        go.Bar(
            x=conf['y_df']['2000'].loc[['China', 'India', 'Poland']].index,
            y=conf['y_df']['2000'].loc[['China', 'India', 'Poland']],
        )
    ],
})<jupyter_output><empty_output><jupyter_text>More- https://plot.ly/python/reference/scatter- https://plot.ly/python/reference/layout  ExerciseReuse config about life expectancy and murder rate from previous exercise and plot (scatter) data for last year available in config.Play around with customization.<jupyter_code># Here solution<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13319800124921924, 'fraction_numerical': 0.01608369768894441, 'mean_word_length': 3.148316062176166, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 36, 'https://': 11, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '635016', 'license': 'MIT', 'n_tokens_mistral': 2151, 'n_tokens_neox': 2019, 'n_words': 494, 'path': 'DASHboard.ipynb', 'repo_name': 'grechut/DASHboard', 'size': '6404'}