Change language

Exploring Data Distribution | Set 1

Terms of Data Dissemination Research

 -" Boxplot -" Frequency Table -" Histogram -" Density Plot 
  • Boxplot: it is based on data percentiles as shown in the image below. The top and bottom of the boxplot represent the 75th th and 25th th percentiles of the data. The extended lines are known as whiskers, which include the range of the rest of the data. 

    To get link to csv file being used, click here .

    Code # 1: Loading Libraries

    import numpy as np

    import pandas as pd

    import seaborn as sns

    import matplotlib.pyplot as plt

    Code # 2: Loading data

    data = pd.read_csv ( " ../ data / state.csv " )

     
    # Add a new derived data column

    data [ ’PopulationInMillions’ ] = data [ ’Population’ ] / 1000000

     

    print (data.head ( 10 ))

    Output:

    Code # 3: BoxPlot

    # BoxPlot Population in millions

    fig, ax1 = plt.subplots ()

    fig.set_size_inches ( 9 15 )

     

    ax1 = sns.boxplot (x = data.PopulationInMillions, orient = "v" )

    ax1.set_ylabel ( " Population by Sta te in Millions " , fontsize = 15 )

    ax1.set_title ( "Population - BoxPlot" , fontsize = 20 )

    Output:

  • Frequency Table: is a tool for spreading data across evenly spaced ranges, segments and tells us how many values ​​are in each segment.

    Code # 1: Adding a column to execute crosstab and group functionality.

    # Perform binning action, binning has been made
    # selected to highlight the output for frequency table

     

    data [ ’PopulationInMillionsBins’ ] = pd.cut (

    data.PopulationInMillions, bins = [ 0 , 1 , 2 , 5 , 8 , 12 , 15 , 20 , 50 ])

     

    print (data.head ( 10 ))

    Output:

    Code # 2: crosstab — frequency table type

    # Cross Tab - frequency table type

     

    pd.crosstab (data.PopulationInMillionsBins, data.Abbreviation, margins = True )

    Output:

    Code # 3: GroupBy — frequency table type

    # Groupby - frequency table type

      

    data.groupby (data.PopulationInMillionsBins) [ ’Abbreviation’ ]. apply ( ’, ’ . join)

    Output:

Shop

Gifts for programmers

Learn programming in R: courses

$FREE
Gifts for programmers

Best Python online courses for 2022

$FREE
Gifts for programmers

Best laptop for Fortnite

$399+
Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best computer for crypto mining

$499+
Gifts for programmers

Best laptop for Sims 4

$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically