please fix this code. There are some errorsin ploting these graphs that I don't know. import pandas as pd import matplot

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

please fix this code. There are some errorsin ploting these graphs that I don't know. import pandas as pd import matplot

Post by answerhappygod »

please fix this code. There are some errorsin ploting these graphs that I don't know.
import pandas as pd
import matplotlib.pyplot as plt
#reading csv file
titanic=pd.read_csv('Titanic_dataset.csv')
#print(first_south)
#filtering data where class is 1 and Port of Embarkation is S
filt=(titanic['Class']==1) & (titanic['Port of Embarkation']=='S')
first_south=titanic[filt][['Survival','Class','Port of Embarkation','Gender','Age group']]
print('List of passenger who is in the first class cabin and boarded from Southampton ')
print('-----------------------------------------')
print(first_south.head())#printing first 5 rows
filt=(titanic['Class']==2) | (titanic['Class']==3)
second_third=titanic[filt][['Survival','Class','Port of Embarkation','Gender','Age group']]
print('List of passenger who is in the second class or third class cabin boarded from Southampton ')
print('-----------------------------------------')
print(second_third.head())#printing first 5 rows
fs=first_south.groupby('Gender').size()#group on Gender and counting number of passengers in each group
print(fs)
#creating bar chart on the grouped data
plt.xlabel('Gender')
plt.ylabel('Number of passengers')
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply