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 valuecounts 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 pdreadcsvhomecodioworkspacecsvstatescsv
# Add your code below
# WRITE YOUR CODE HERE
# FREEZE CODE BEGIN
printComparing gender distribution between Alberta and Connecticut:"
if albertadistribution.getMale connecticutdistribution.getMale:
printAlberta has more males than Connecticut."
else:
printConnecticut has more males than Alberta."
if albertadistribution.getFemale connecticutdistribution.getFemale:
printAlberta has more females than Connecticut."
else:
printConnecticut 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
