Data Visualization With Python Seaborn - Acervo Lima
Data Visualization With Python Seaborn - Acervo Lima
Pandas and Seaborn are one of these packages and facilitate the import and analysis of data.
In this article, we will use Pandas and Seaborn to analyze the data.
Pandas
Pandassuggest tools to clean and process your data. It's the most
popular used for data analysis. In pandas, a data table is called a
data frame.
Example 1:
Create DataFrame
df = pd.DataFrame( data )
Exit:
Example 2: load the dataCSVof the system and match them via pandas.
# import module
import pandas
Exit
Seaborn
Seaborn is an amazing visualization library for plotting statistical graphs.
in Python. It is built on top of the librarymatplotliband is also closely
integrated into the data structures ofpandas.
Installation
Importing libraries
import numpy as np
import seaborn as sns
Go out:
Line graph
Point cloud
Box plot
Point diagram
Counting of counting
Violin plot
Swarm plot
Bar chart
KDE Trace
Line graph:
Line plotIt is the most popular plot to trace a relationship between x and y with the possibility of
several semantic groupings.
Parameters:
Example 1:
# import module
import seaborn as sns
import pandas
# loading csv
data = pandas.read_csv("nba.csv")
Exit:
Example 2: use the hue parameter to plot the graph.
# import module
import seaborn as sns
import pandas
plot
sns.lineplot(data['Age'], data['Weight'], hue=data['Position'])
Go out:
Point cloud:
Scatter plotCan be used with several semantic groupings that can help to do well
understand in a graph in relation to continuous/categorical data. It can plot a
two-dimensional graph.
Parameters:
x, y: Input data variables that must be numeric.
Returns: This method returns the Axes object with the plot drawn on it.
Example 1:
# import module
import seaborn
import pandas
# load csv
data = pandas.read_csv("nba.csv")
# plotting
seaborn.scatterplot(data['Age'], data['Weight'])
Exit
import seaborn
import pandas
data = pandas.read_csv("nba.csv")
Go out:
Mustache box:
The minimum
First quartile or 25%
Median (second quartile) or 50%
Third quartile or 75%
Maximum
Syntax:
None
Parameters:
Returns: It returns the Axes object with the plot drawn on top.
Draw the box plot with Pandas:
Example 1:
import module
import seaborn as sns
import pandas
Leave
Example 2 :
# import module
import seaborn as sns
import pandas
Go out
Parameters:
Example 1:
# import module
import seaborn as sns
import pandas
Exit:
Example 2:
# import module
import seaborn
seaborn.set(style = 'whitegrid')
Exit:
Swarm plot:
Parameters:
Example 1:
# import module
import seaborn
seaborn.set(style = 'whitegrid')
Exit
Example 2:
# import module
import seaborn
seaborn.set(style = 'whitegrid')
Go out
Bar chart:
Barplotrepresents an estimate of the central tendency for a numerical variable with the
height of each rectangle and provides an indication of the uncertainty around this estimate at
the help of error bars.
Parameters:
Returns: Returns the Axes object with the plot drawn on it.
# import module
import seaborn
seaborn.set(style = 'whitegrid')
Go out:
Example 2:
import module
import seaborn
seaborn.set(style = 'whitegrid')
Go out:
Scatter plot:
Parameters:
Example:
# import module
import seaborn
seaborn.set(style = 'whitegrid')
Go out:
Graphic counting:
Parameters:
x, y: this parameter takes the names of the variables in the data or the
vector data, optional, the inputs to plot the data from
long form.
hue: (optional) This parameter takes the name of the column for encoding.
colors.
(optional) This parameter takes DataFrame, array or list of arrays,
data set for tracing. If x and y are absent, this is
interpreted as a wide shape. Otherwise, it should be long.
Example:
# import module
import seaborn
seaborn.set(style = 'whitegrid')
Exit:
KDE trace:
KDE Plotdescribe how Kernel Density Estimate is used to visualize probability density
of a continuous variable. It represents the probability density at different values in a
variable continues. We can also plot a single graph for multiple samples, this
which allows for a more effective visualization of data.
Parameters:
Example 1:
# importing the required libraries
from sklearn import datasets
import pandas as pd
import seaborn as sns
iris_df['Target'] = iris.target
Exit
Example 2:
# import module
import seaborn as sns
import pandas
To go out:
Before we begin, let's have a brief introduction to bivariate and univariate data:
Bivariate data: This type of data involves two different variables. The analysis of this type
The data deals with causes and relationships, and the analysis is carried out to uncover the relationship.
between the two variables.
Univariate data: This type of data consists of a single variable. Data analysis
univariate is therefore the simplest form of analysis since the information pertains to a single
grandeur that changes. It does not deal with causes or relationships, and the main objective of the analysis.
is to describe the data and find patterns that exist in it.
Let's see an example of perturbation of bivariate data:
# import module
import seaborn as sns
import pandas
Leave:
# import module
import seaborn as sns
import pandas
Exit:
# import module
import seaborn as sns
import pandas
sns.distplot(data['Age'])
Exit
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn
the basics.
Article written bykumar_satyamand translated by Acervo Lima of Data Visualization with Python
Seaborn. License:CCBY-SA
Similar Articles:
1. Count unique values with Pandas by groups
2.Filter Pandas DataFrame by hour
3.Systematic sampling in pandas
4.Sort DataFrame based on the frequency of rows in Pandas
← Previous article
Leave a comment
Your email address will not be published. Required fields are marked with *
Write here...
Name*
E-mail*
Website
Save my name, my email, and my website in the browser for my next time.
comment
twenty - 9 =
Post a comment »
Recent Articles
numpy.diag_indices() in Python
Recent comments
Archives
September 2021
February 2021