I want to compare the number of survivors with gender. I have something like:
Name, Survived, Sex
John, 0, male
Ana, 1, female
Leo, 1, male
Peter, 0, male
And trying to create a bar chart which should look like here: https://pythonspot.com/wp-content/uploads/2015/07/barchart_python.png.webp
I tried this way
import pandas as pd
from matplotlib import pyplot as plt
import numpy as np
data = pd.read_csv('titanic_data/train.csv')
figure1 = plt.bar(range(4), data[data['Sex']=='male']['Survived'].value_counts(), label='Male')
figure2 = plt.bar(range(4), data[data['Sex']=='female']['Survived'].value_counts(), label='Female')
plt.legend()
plt.xticks(np.arange(4), rotation=0)
plt.title("Third class survivors")
plt.show()
But it says "ValueError: shape mismatch: objects cannot be broadcast to a single shape". What should I do?

