Write a program that loads in historical data on popular baby-names for the last 100 years. You can type in a name, and it graphs the rank of that name over time. A high ranking, like 5, means the name was the 5th most popular that year (top of the graph), while a low ranking like 879 means the name was not that popular (bottom of the graph).    Write it in python the latest version   The first function you will write and test is the clean_data function. The function is described in the starter code in a function header comment above the function. Here is the function:   def clean_data(list, x): #TODO: write your code here    pass   Take a look at the first few lines of the data file: A 83 140 228 286 426 612 486 577 836 0 0 Aaliyah 0 0 0 0 0 0 0 0 0 380 215 Aaron 193 208 218 274 279 232 132 36 32 31 41     Each line is a baby name followed by how popular the name was in 11 different years. Each number is a ranking, so Aaron was 193th most popular name in 1900 and 41st most popular name in 2000. The lower the number, the more popular the name. However, if the name was not popular enough to make the list in a particular year, a zero was recorded. If we plot the data as is, a name that was so unpopular that it didn’t make the list (ranked 0) will appear most popular (since lower means more popular). Therefore, we need to clean up the data a bit in order for it to make sense.   The function clean_data has two parameters. The first parameter is a list (e.g. a list of rankings by year for a particular baby name). The second parameter is a value x. The function will do in-place modification of the parameter list and replace all zeros with the value x.   You will write this function generally. Here are three of the cases you should test:   # test 1 # before data is cleaned list1 = [0, 4, 3, 2, 0, 6, 7, 8, 3, 0, 7, 7, 8, 3, 0] x1 = 5 # after data is cleaned list1 = [5, 4, 3, 2, 5, 6, 7, 8, 3, 5, 7, 7, 8, 3, 5]   # test 2 # before data is cleaned list2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] x2 = 10001 # after data is cleaned list2 = [10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001]   # test 3 # before data is cleaned list3 = [857, 797, 972, 883, 0, 0, 0, 0, 0, 0, 0] x3 = 1113 # after data is cleaned list3 = [857, 797, 972, 883, 1113, 1113, 1113, 1113, 1113, 1113, 1113]   here is what I wrote for the clean data function:   def clean_data(lists, x):   for i in range(0, len(lists)):     if lists[i] == 0:       lists[i] = x   return lists   Then: Next step is   You are going to writing a script that takes in a list of names as a single input string      namestring = input("Enter baby names: ")   For example, the prompt with the input could look like this:  python3 main.py Enter baby names: Mary Megan Isabelle   Your code should produce the following plot [1]:   [1] The first image uploaded   Plot should appear in your file tree with the filename: MaryMeganIsabelle.png.   Another example is if the prompt with the input is: python3 main.py Enter baby names: Mario Marie Mary Marta   Your code should produce the following plot [2]:   [2] The second image uploaded   Plot should appear in your file tree with the filename: MarioMarieMaryMarta.png.   Once you are done developing, remove plt.show(), type:   plt.ion()   before your plot commands and type:   plt.savefig("filename.png")   After the plotting commands (but name the file properly) to create an image file that will get created in the file tree on the left. Make sure you final code runs to completion without hanging in the terminal. In other words, it is ready for the next command or to be run again.     Your code should run for lots of different name combinations. You only need to handle names that are in the data file. You don’t to handle the case where the name is spelled wrong, not capitalized properly, or any other error handling. Assume the names are typed in correctly. Your code should be able to plot any number of names listed.   the data file is called: names-data.txt:   the file for the data text link is: https://docs.google.com/document/d/1r59aYMhumgWUXqGDbyDkIsycF4s7yCwl6aNlH8zG12g/edit?usp=sharing

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Write a program that loads in historical data on popular baby-names for the last 100 years. You can type in a name, and it graphs the rank of that name over time. A high ranking, like 5, means the name was the 5th most popular that year (top of the graph), while a low ranking like 879 means the name was not that popular (bottom of the graph)
 
Write it in python the latest version
 
The first function you will write and test is the clean_data function. The function is described in the starter code in a function header comment above the function. Here is the function:
 
def clean_data(list, x):
#TODO: write your code here 
  pass
 
Take a look at the first few lines of the data file:
A 83 140 228 286 426 612 486 577 836 0 0
Aaliyah 0 0 0 0 0 0 0 0 0 380 215
Aaron 193 208 218 274 279 232 132 36 32 31 41
 
  Each line is a baby name followed by how popular the name was in 11 different years. Each number is a ranking, so Aaron was 193th most popular name in 1900 and 41st most popular name in 2000. The lower the number, the more popular the name. However, if the name was not popular enough to make the list in a particular year, a zero was recorded. If we plot the data as is, a name that was so unpopular that it didn’t make the list (ranked 0) will appear most popular (since lower means more popular). Therefore, we need to clean up the data a bit in order for it to make sense.
  The function clean_data has two parameters. The first parameter is a list (e.g. a list of rankings by year for a particular baby name). The second parameter is a value x. The function will do in-place modification of the parameter list and replace all zeros with the value x.
 
You will write this function generally. Here are three of the cases you should test:
 
# test 1
# before data is cleaned
list1 = [0, 4, 3, 2, 0, 6, 7, 8, 3, 0, 7, 7, 8, 3, 0]
x1 = 5
# after data is cleaned
list1 = [5, 4, 3, 2, 5, 6, 7, 8, 3, 5, 7, 7, 8, 3, 5]
 
# test 2
# before data is cleaned
list2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
x2 = 10001
# after data is cleaned
list2 = [10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001]
 
# test 3
# before data is cleaned
list3 = [857, 797, 972, 883, 0, 0, 0, 0, 0, 0, 0]
x3 = 1113
# after data is cleaned
list3 = [857, 797, 972, 883, 1113, 1113, 1113, 1113, 1113, 1113, 1113]
 
here is what I wrote for the clean data function:
 
def clean_data(lists, x):
  for i in range(0, len(lists)):
    if lists[i] == 0:
      lists[i] = x
  return lists
 
Then: Next step is
 
You are going to writing a script that takes in a list of names as a single input string
     namestring = input("Enter baby names: ")
 
For example, the prompt with the input could look like this:
 python3 main.py Enter baby names: Mary Megan Isabelle
 
Your code should produce the following plot [1]:
 
[1] The first image uploaded
 
Plot should appear in your file tree with the filename: MaryMeganIsabelle.png.
 
Another example is if the prompt with the input is:
python3 main.py Enter baby names: Mario Marie Mary Marta
 
Your code should produce the following plot [2]:
 
[2] The second image uploaded
 
Plot should appear in your file tree with the filename: MarioMarieMaryMarta.png.
 
Once you are done developing, remove plt.show(), type:
  plt.ion()
 
before your plot commands and type:
  plt.savefig("filename.png")
 
After the plotting commands (but name the file properly) to create an image file that will get created in the file tree on the left. Make sure you final code runs to completion without hanging in the terminal. In other words, it is ready for the next command or to be run again.
 
 
Your code should run for lots of different name combinations. You only need to handle names that are in the data file. You don’t to handle the case where the name is spelled wrong, not capitalized properly, or any other error handling. Assume the names are typed in correctly. Your code should be able to plot any number of names listed.
 
the data file is called: names-data.txt:
 
the file for the data text link is: https://docs.google.com/document/d/1r59aYMhumgWUXqGDbyDkIsycF4s7yCwl6aNlH8zG12g/edit?usp=sharing
This line graph illustrates the popularity ranking of four baby names, "Mario," "Marie," "Mary," and "Marta," over the course of the 20th century, divided by decade. The y-axis represents the ranking from 0 to 1000, where 0 is the most popular. The x-axis covers the years from 1900 to 2000.

1. **Mario (Blue line):** 
   - Starts at a mid-ranking position.
   - Experiences a slight upward trend, maintaining relatively stable popularity.

2. **Marie (Orange line):** 
   - Begins with high popularity, ranking closer to the top.
   - Shows a gradual decline, becoming less popular over time.

3. **Mary (Green line):**
   - Starts as the most popular name among the four.
   - Maintains high popularity throughout the century, with a slight decline near the end.

4. **Marta (Red line):**
   - Starts at a lower popularity ranking.
   - Experiences a significant dip, hitting a low in popularity around the 1960s.
   - Shows a resurgence towards the end of the century, rebounding close to the top.

Each line is distinctively marked with different colors and styles for easy differentiation. The legend on the right provides a quick reference for identifying each name represented on the graph.
Transcribed Image Text:This line graph illustrates the popularity ranking of four baby names, "Mario," "Marie," "Mary," and "Marta," over the course of the 20th century, divided by decade. The y-axis represents the ranking from 0 to 1000, where 0 is the most popular. The x-axis covers the years from 1900 to 2000. 1. **Mario (Blue line):** - Starts at a mid-ranking position. - Experiences a slight upward trend, maintaining relatively stable popularity. 2. **Marie (Orange line):** - Begins with high popularity, ranking closer to the top. - Shows a gradual decline, becoming less popular over time. 3. **Mary (Green line):** - Starts as the most popular name among the four. - Maintains high popularity throughout the century, with a slight decline near the end. 4. **Marta (Red line):** - Starts at a lower popularity ranking. - Experiences a significant dip, hitting a low in popularity around the 1960s. - Shows a resurgence towards the end of the century, rebounding close to the top. Each line is distinctively marked with different colors and styles for easy differentiation. The legend on the right provides a quick reference for identifying each name represented on the graph.
The graph titled "Most Popular Baby Names, by Decade" depicts the ranking trends of three names—Mary, Megan, and Isabelle—across the 20th century into the early 21st century.

**Graph Details:**
- **X-axis (Years):** Displays decades from 1900 to 2000.
- **Y-axis (Ranking):** Ranges from 0 to 1000, with 0 being the most popular ranking.

**Name Trends:**
- **Mary (Blue Line):** Consistently popular from 1900 to around 1960, maintaining a ranking near 0. Its popularity declines steadily after 1960.
- **Megan (Orange Line):** Absent from top rankings until around 1960, when it begins to rise sharply, peaking around 1980, and then declines in popularity moving into 2000.
- **Isabelle (Green Line):** Starts with low popularity, then sees an upward trend after 1980, increasing steadily toward 2000.

**Legend:**
- Blue circles represent Mary.
- Orange circles represent Megan.
- Green circles represent Isabelle.

Overall, the graph demonstrates shifts in name popularity over time, highlighting cultural or societal trends influencing baby names.
Transcribed Image Text:The graph titled "Most Popular Baby Names, by Decade" depicts the ranking trends of three names—Mary, Megan, and Isabelle—across the 20th century into the early 21st century. **Graph Details:** - **X-axis (Years):** Displays decades from 1900 to 2000. - **Y-axis (Ranking):** Ranges from 0 to 1000, with 0 being the most popular ranking. **Name Trends:** - **Mary (Blue Line):** Consistently popular from 1900 to around 1960, maintaining a ranking near 0. Its popularity declines steadily after 1960. - **Megan (Orange Line):** Absent from top rankings until around 1960, when it begins to rise sharply, peaking around 1980, and then declines in popularity moving into 2000. - **Isabelle (Green Line):** Starts with low popularity, then sees an upward trend after 1980, increasing steadily toward 2000. **Legend:** - Blue circles represent Mary. - Orange circles represent Megan. - Green circles represent Isabelle. Overall, the graph demonstrates shifts in name popularity over time, highlighting cultural or societal trends influencing baby names.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 5 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

How would you be able to do this with 2 or 3 user defined function? For easier readabillity and without importing anything else besides import matplotlib.pyplot as plt and not SYS or the cycler?

Solution
Bartleby Expert
SEE SOLUTION
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY