Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make a bar plot using seaborn library

I am trying to make a bar plot on my airline satisfaction data project, I am trying to compare Gender vs. satisfaction answers. I tried the code below in python with sea-born library. I tried plotting both but keep getting DataFrame object has no attribute . I expected a bar plot on Gender vs. Satisfaction.

airline_vis = airline_data.loc[airline_data.columns.str.contains('satisfied|unsatisfied'),:]

sns.countplot(airline_vis.date_time.dt.month,
              hue=airline_vis.columns)
plt.xlabel('Gender')
plt.ylabel('satisfaction')
sns.despine()
plt.legend(loc='upper right')
plt.savefig('gender breakdown')
plt.show()

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I hope this solve your problem:

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

# Creating a dictionary with airline gender and satisfaction data
data = {
        'Gender': ['Male', 'Female'],
        'Satisfaction': [3.7, 4.8] # Change satisfaction here
        }

# Transforming the dictionary into a dataframe
df = pd.DataFrame(data)

# Plotting the bar graph
sns.barplot(x="Gender", y="Satisfaction", data=df)

# Defining the chart title
plt.title("Airline Satisfaction by Gender")

# Showing the chart
plt.show()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading