Open In App

Python Seaborn get_dataset_names() Method

Last Updated : 25 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Seaborn is a Python data visualization library based on Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. In this article, we will learn about the Python seaborn.get_dataset_names() Method.

What is the Seaborn get_dataset_names() Method?

The seaborn.get_dataset_names() method is used to retrieve the complete list of names of all the built-in or sample datasets provided by the seaborn library. The datasets provided by the Seaborn library are returned as a Pandas dataframe which can later be used for creating visualization or analytical reports.

Syntax of Python Seaborn get_dataset_names() Method

seaborn.get_dataset_names()

Parameters: This method doesn’t take parameters.

Returns: It returns a list of names of built-in datasets in seaborn

Seaborn get_dataset_names() Method Examples

Below are examples of Python seaborn.get_dataset_names() Method:

  • Loading and Visualizing a Dataset
  • Checking Dataset Availability
  • Looping Through Available Datasets

Loading and Visualizing a Dataset

In this example, below code uses seaborn to access built-in datasets. It retrieves the list of available datasets and loads the ‘iris’ dataset. Finally, it displays the first few rows of the ‘iris‘ dataset for visualization.

Python3
import seaborn as sns

# Get the list of available datasets
datasets = sns.get_dataset_names()

# Load the 'iris' dataset
iris = sns.load_dataset('iris')

print(iris.head())

Output

  sepal_length  sepal_width  petal_length  petal_width species
0           5.1          3.5           1.4          0.2  setosa
1           4.9          3.0           1.4          0.2  setosa
2           4.7          3.2           1.3          0.2  setosa
3           4.6          3.1           1.5          0.2  setosa
4           5.0          3.6           1.4          0.2  setosa

Checking Dataset Availability

In this example, below code imports seaborn and retrieves the list of built-in datasets. It checks if the ‘titanic‘ dataset is included in the list and prints a message indicating its availability status.

Python3
import seaborn as sns

# Get the list of available datasets
datasets = sns.get_dataset_names()

if 'titanic' in datasets:
    print("The 'titanic' dataset is available.")
else:
    print("The 'titanic' dataset is not available.")

Output

The 'titanic' dataset is available.

Looping Through Available Datasets

In this example, below code imports seaborn and fetches a list of built-in datasets. It then iterates through each dataset in the list, printing out the name of each dataset.

Python3
import seaborn as sns

# Get the list of available datasets
datasets = sns.get_dataset_names()

for dataset in datasets:
    print(dataset)

Output

anagrams
anscombe
attention
brain_networks
car_crashes
diamonds
dots
dowjones
exercise
flights
fmri
geyser
glue
healthexp
iris
mpg
penguins
planets
seaice
taxis
tips
titanic

Previous Article
Next Article

Similar Reads

Python - seaborn.jointplot() method
Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Seaborn helps resolve the two major problems faced by Matplotlib; the problems are ? Default Matplotlib parametersWorking with data frames As Seaborn compliments and extends Matplotlib,
3 min read
Python - seaborn.factorplot() method
Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated to the data structures from pandas. seaborn.factorplot() method seaborn.factorplot() meth
5 min read
Python - seaborn.lmplot() method
Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated to the data structures from pandas. seaborn.Implot() method seaborn.lmplot() method is us
7 min read
Seaborn.barplot() method in Python
Seaborn is a Python data visualization library based on Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. There is just something extraordinary about a well-designed visualization. The colors stand out, the layers blend nicely together, the contours flow throughout, and the overall package n
4 min read
Python - seaborn.pairplot() method
Prerequisite: Seaborn Programming Basics Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Seaborn helps resolve the two major issues while working with Matplotlib: Default Matplotlib parametersWorking with data frames As Seaborn compli
2 min read
Python - seaborn.FacetGrid() method
Prerequisite: Seaborn Programming Basics Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Seaborn helps resolve the two major problems faced by Matplotlib; the problems are ? Default Matplotlib parametersWorking with data frames As Sea
3 min read
Python - seaborn.PairGrid() method
Prerequisite: Seaborn Programming Basics Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Seaborn helps resolve the two major problems faced by Matplotlib; the problems are ? Default Matplotlib parametersWorking with data frames As Sea
3 min read
seaborn.lineplot() method in Python
Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. The colors stand out, the layers blend nicely together, the contours flow throughout, and the overall package not only has a nice aesthetic quality, but it provides meaningful insights t
2 min read
Python - seaborn.regplot() method
Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Seaborn helps resolve the two major problems faced by Matplotlib; the problems are ? Default Matplotlib parametersWorking with data frames As Seaborn compliments and extends Matplotlib,
3 min read
Python - seaborn.pointplot() method
Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated to the data structures from pandas. seaborn.pointplot() :This method is used to show poin
3 min read
Article Tags :
Practice Tags :