How to Create Boxplot of All Variables of Dataframe in Python

To create a boxplot of all variables of a dataframe in Python, you can use the boxplot() function from the seaborn library.

The following example shows how to create a boxplot of all variables of a dataframe in Python using the boxplot() function.

Using boxplot() Function

We can use the boxplot() function to create a boxplot of all variables in a dataframe.

Let’s see how to use the boxplot() function in Python:

# Import libraries
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt

# Create dataframe
office_stuff = pd.DataFrame({
    'Date': ['01-03-2023', '01-03-2023', '01-03-2023', '01-03-2023', '02-03-2023', '02-03-2023'],
    'Product_Code': ['A-101', 'A-102', 'A-103', 'B-101', 'B-102', 'B-104'],
    'Product_Name': ['Laptop', 'Mobile', 'Printer', 'Keyboard', 'Scanner', 'Mouse'],
    'Price': [4500, 550, 250, 50, 350, 50],
    'Status': [1, 1, 1, 0, 1, 1]
})

# Create boxplot
sns.boxplot(data=office_stuff, orient="h")

# Show boxplot
plt.show()

Output: 👇️

Box Plot

In this example, we use the boxplot() function to create a boxplot from the dataframe office_stuff.

The orient=“h” parameter specifies that we want a horizontal boxplot.

The output shows the boxplot created from all variables in the dataframe.

Conclusion

We can use the boxplot() function from the seaborn library to create a boxplot of all variables in a dataframe in Python.