Question: Use the value _ counts ( ) function to count the frequency of each gender in each state. Compare the gender distribution in two specific

Use the value_counts() function to count the frequency of each gender in each state.
Compare the gender distribution in two specific states, Alberta and 'Connecticut.
Use conditional statements to determine which state has a higher frequency of males and which state has a higher frequency of females.
Print the results of your comparison.
Starter Code:
import pandas as pd
# Load the data
data = pd.read_csv('/home/codio/workspace/csv/states.csv')
# Add your code below
# WRITE YOUR CODE HERE
# FREEZE CODE BEGIN
print("Comparing gender distribution between Alberta and Connecticut:")
if alberta_distribution.get('Male',0)> connecticut_distribution.get('Male',0):
print("Alberta has more males than Connecticut.")
else:
print("Connecticut has more males than Alberta.")
if alberta_distribution.get('Female',0)> connecticut_distribution.get('Female',0):
print("Alberta has more females than Connecticut.")
else:
print("Connecticut has more females than Alberta.")
# FREEZE CODE END

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!