Seaborn.get_data_home() method



The Seaborn.get_data_home() method is used to return a path to the cache directory for inbuilt datasets.

Once the path is returned, the directory is used by the load_dataset() method. If the argument of this method, data_home, is not provided; it will use a directory specified by the seaborn_data environment variable (if it exists) or otherwise default to an OS-appropriate user cache location.

Syntax

Following is the syntax of the get_data_home() method −

sns.get_data_home()

Parameters

This method takes no parameters

Return value

Upon calling thisd method just returns the path to the cache directory like mentioned above. This method is generally followed by the load_dataset() method since upon understanding which directory the user is located at, then the user can load the dataset and proceed with plotting plots.

Example

The working of this method is seen below. Upon calling the method as shown below. The following output is obtained.

import seaborn as sns
import matplotlib.pyplot as plt
path = sns.get_data_home()
print(path)

Output

The path to the cache directory is obtained and in this case it is the following.

'/root/seaborn-data'
seaborn_utility_functions_introduction.htm
Advertisements