- Seaborn Tutorial
- Seaborn - Home
- Seaborn - Introduction
- Seaborn - Environment Setup
- Importing Datasets and Libraries
- Seaborn - Figure Aesthetic
- Seaborn- Color Palette
- Seaborn - Histogram
- Seaborn - Kernel Density Estimates
- Visualizing Pairwise Relationship
- Seaborn - Plotting Categorical Data
- Distribution of Observations
- Seaborn - Statistical Estimation
- Seaborn - Plotting Wide Form Data
- Multi Panel Categorical Plots
- Seaborn - Linear Relationships
- Seaborn - Facet Grid
- Seaborn - Pair Grid
- Function Reference
- Seaborn - Function Reference
- Seaborn Useful Resources
- Seaborn - Quick Guide
- Seaborn - Useful Resources
- Seaborn - Discussion
Seaborn.get_dataset_names() method
Seaborn.get_dataset_names() method is used to view the names of all the in built datasets from the seaborn library. For the purpose of describing seaborn or creating reproducible examples for bug complaints, this function offers rapid access to a few example datasets.
It is not required for everyday use. To create an appropriate ordering for categorical variables, a minor amount of preprocessing has been conducted to some of the datasets.
Syntax
Following is the syntax of the seaborn.get_dataset_names() method −
seaborn.get_dataset_names()
Parameters
This method takes no parameter
Return value
This method returns a list of all the names of the datasets inbuilt in Seaborn.
Seaborn.get_dataset_names() method
In order to plot graphs, we require data and in case, data is not available readily for your use in the required format and containing desired data, you can use the datasets present in the Seaborn library.
Seaborn contains various default datasets in addition to being a statistical charting toolkit. We'll use the one of the in-built datasets as an example of a default dataset.
In order to view all the datasets available in the Seaborn library, the following method can be used to do so.
Example 1
The get_dataset_names() method helps to retrieve all the names of the in-built datasets available in Seaborn.
import seaborn as sns list = sns.get_dataset_names() print(list)
Output
Upon, executing this example, the following list is obtained.
['anagrams', 'anscombe', 'attention', 'brain_networks', 'car_crashes', 'diamonds', 'dots', 'exercise', 'flights', 'fmri', 'gammas', 'geyser', 'iris', 'mpg', 'penguins', 'planets', 'taxis', 'tips', 'titanic']
Using any one of these in built datasets, graphs can be plotted. To load datasets, the seaborn.load_dataset() method can be used to do so.
The load_dataset() method helps to load the dataset with the name into a data structure. For the purpose of this example, we will load the tips dataset.
Tips=seaborn.load_dataset('tips')
The above line of code helps to load the dataset with the name 'tips' into a data structure called tips. Thus, this method helps in loading the datasets from the library.
Example 2
Following is an example which loads the titanic dataset using get_dataset_names() method −
import seaborn as sns import matplotlib.pyplot as plt list = sns.get_dataset_names() name = list[21] dts= sns.load_dataset(name) dts.head() sns.relplot(data=dts, x="age", y="fare") plt.show()
Output
Following is the output of the above example −
Example 3
Following is an example which loads the tips dataset using get_dataset_names() method −
import seaborn as sns import matplotlib.pyplot as plt list = sns.get_dataset_names() name = list[20] tips=sns.load_dataset(name) tips.head() sns.catplot(data=tips,x="sex",y="tip",hue="time",height=5, aspect=.8) plt.show()
Output
This generates the following output −
Example 4
Let us see another example −
import seaborn as sns import matplotlib.pyplot as plt list = sns.get_dataset_names() name = list[11] print(name) exercise=sns.load_dataset("exercise") exercise.head() g=sns.PairGrid(exercise) g.map_upper(sns.scatterplot) g.map_lower(sns.kdeplot) g.map_diag(sns.ecdfplot) plt.show()
Output
On executing, the above example generates the following example −
To Continue Learning Please Login
Login with Google