Skip to main content

Seaborn: Importing Pandas DataFrame for Visualization

Seaborn is a Data Visualization library that is based on Matplotlib. It is a library present in python which is used for drawing attractive and informative statistical graphics.

In this article, we will see how we can use pandas dataframe for visualization in seaborn.

Step-1: Import the required libraries:

import pandas as pd
import random
import matplotlib.pyplot as plt
import seaborn as sns

Step-2: Creating a Dataset

df = pd.DataFrame()
df['x'] = random.sample(range(1, 100),20)
df['y'] = random.sample(range(1, 100),20)

Step-3: Creating Plots

Scatter Plot

sns.lmplot('x', 'y', data=df, fit_reg=False)

Output

scatter

KDE Plot

sns.kdeplot(df.x, df.y)

Output

kde

Distplot

sns.distplot(df.y)

Output:

dist

Strip Plot

sns.stripplot(df.y, df.x)

Output

strip

Submitted by devanshi.srivastava on January 18, 2022

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.