Reader small image

You're reading from  Interactive Dashboards and Data Apps with Plotly and Dash

Product typeBook
Published inMay 2021
Reading LevelBeginner
PublisherPackt
ISBN-139781800568914
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Elias Dabbas
Elias Dabbas
author image
Elias Dabbas

Elias Dabbas is an online marketing and data science practitioner. He produces open-source software for building dashboards, data apps, as well as software for online marketing, with a focus on SEO, SEM, crawling, and text analysis.
Read more about Elias Dabbas

Right arrow

Creating a histogram

We want to see how we can get the distribution of a sample of data and get an idea of where values are concentrated, as well as how much variability/spread it has. We will do this by creating a histogram.

As always, we'll start with the simplest possible example:

  1. We open the poverty DataFrame and create a subset of it, containing only countries and data from the year 2015:
    import pandas as pd
    poverty = pd.read_csv('data/poverty.csv')
    df = poverty[poverty['is_country'] & poverty['year'].eq(2015)]
  2. Import Plotly Express and run the histogram function with df as the argument to the data_frame parameter and the indicator of our choice for the x parameter:
    import plotly.express as px
    gini = 'GINI index (World Bank estimate)'
    px.histogram(data_frame=df, x=gini)

    As a result, we get the histogram that you can see in Figure 8.1:

Figure 8.1 – A histogram of the Gini indicator

Figure 8.1 – A histogram of the Gini indicator...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Interactive Dashboards and Data Apps with Plotly and Dash
Published in: May 2021Publisher: PacktISBN-13: 9781800568914

Author (1)

author image
Elias Dabbas

Elias Dabbas is an online marketing and data science practitioner. He produces open-source software for building dashboards, data apps, as well as software for online marketing, with a focus on SEO, SEM, crawling, and text analysis.
Read more about Elias Dabbas