Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help!! using pandas/python will def upvote if its correct both 2a and 2b # filter 1995 names names_95 = baby_names[baby_names.Year == 1995] How many individuals

help!! using pandas/python will def upvote if its correct

both 2a and 2b

image text in transcribedimage text in transcribed

\# filter 1995 names names_95 = baby_names[baby_names.Year == 1995] How many individuals were counted in total in 1995 ? We can address that by computing a sum of the counts: # n for 1995 names_95.Count.sum() =494580 What is the typical frequency of all names in 1995 ? We can address that by computing the average count: \# average count for a name in 1995 names_95.Count.mean() :81.18516086671043 Question 2a Compute the maximum count of names given in 1995 and store this as names_95_max_count. Use this value to filter names_95 and find which name is the most frequent in that year. Store the filtered dataframe as names_95_most_common_name . names_95_max_count = names_95.Name.sum() names_95_most_common_name = names_95_max_count. Count.sum() print("Number of people with the most frequent name in 1995 is :", names_95_max_count, "people") print("Most frequent name in 1995 is:", names_95_most_common_name.values[0]) AttributeError Traceback (most recent call last) in 1 names_95_max_count = names_95. Name. sum ( ) 2 names_95_most_common_name = names_95_max_count.Count.sum() 3 5 AttributeError: 'str' object has no attribute 'Count' ]: \# number of individuals by sex names_95_bysex.Count.sum( ) The most frequent boy and girl names can be found using .idxmax ( ) groupwise to obtain the index of the first occurence of the maximum count for each sex, and then slicing with . loc : ]: \# first most common names by sex names_95. loc[names_95_bysex.Count.idxmax ( ), : ] Since . idxmax () gives the index of the first occurrence, these are the alphabetically first most common names; there could be ties. You know from Q2a that there are no ties for the male names; another filtering step can be used to check for ties among the female names. ]: \# ties? names_95[names_95_bysex.Count. max(), values [ 0]== names_95 ['Count'] ] So, no ties. Question 2b Are there more girl names or boy names in 1995? Use the grouped dataframe names_95_bysex with the . count ( ) aggregation to find the total number of names for each sex. Store the female and male counts as girl_name_count and boy_name_count , respectfully

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago