Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Very Lost
#1
I'm currently working on a hw assignment which may be very basic for some but they are not really teaching us properly in my opinion. we are being asked to identify and store information in the below questions. What im struggling with is how do I identify the row/column in the list, do the rows/colums in the excel table reflect on a 1 to 1 to the list in python? So would column A = position zero in my list?

Find the relevant information
Where is the number of adults in the US for each marital status? Which row(s)? Which column(s)? Which indices do these row/column values correspond to in the nested list data_list?
Where is the total number of adults in the US? Which row(s)? Which column(s)? Which indices do these row/column values correspond to in the nested list data_list?
Where is the number of adults in the south for each marital status? Which row(s)? Which column(s)? Which indices do these row/column values correspond to in the nested list data_list?
Where is the total number of adults in the south? Which row(s)? Which column(s)? Which indices do these row/column values correspond to in the nested list data_list?
https://house-quest.codio.io/hint1.png
https://house-quest.codio.io/hint2.png

Store what you need
We need to use the column and row indices you identified in Step 1 to extract the data we need from the table that was provided in the CSV file (and subsequently stored in Python as data_list in Step 0).
In the second cell in the Jupyter notebook, you will see the following steps:
1. Define the status labels, in the same order we will be using them throughout the analysis.
2. Extract the total number of adults in the US from the data table.
• QUESTION 1: What is the data type of total_US_adults? If it is a list, what type of objects does it contain?
1. Extract the total number of adults in the US with each marital status from the data table.
• QUESTION 2: What is the data type of total_US_status? If it is a list, what type of objects does it contain?
1. Extract the total number of adults in the south region from the data table.
2. Extract the total number of adults in the south region with each marital status from the data table.
3. Use the numerators and denominators we’ve obtained in the previous steps to compute the percent of the adult population (in the US and the south, respectively) with each marital status.
• QUESTION 3: What is the data type of percent_south_status? If it is a list, what type of objects does it contain?
• QUESTION 4: Where do the 3, 2, 9, 4, 10, 74, and 81 indices come from? Explain each one and what its purpose is.
Write your answers to the QUESTIONS above in place of the red line in the Step 2 cell of the Jupyter notebook.

Here is the code we were given
##### Step 0 ##### 

import csv

filename = "lab2_cps_maritalstatus_2018.csv"
fileobject = open(filename)
all_data = csv.reader(fileobject)
data_list = list(all_data)
fileobject.close()

for i in range(len(data_list)):
    for j in range(len(data_list[i])):
        if i > 2 and j > 0:
            try:
                data_list[i][j] = int(data_list[i][j])
            except:
                data_list[i][j] = 0

##### Step 2 #####

status_labels = ["Married, Spouse Present", "Married, Spouse Absent", "Widowed", 
                 "Divorced", "Separated", "Never Married"]

US_adults = data_list[3][2:9]
total_US_adults = sum(US_adults)

just_status = data_list[4:10]
total_US_status = []
for status in just_status:
    total_US_status.append(sum(status[2:9]))
percent_US_status = []
for status in total_US_status:
    percent_US_status.append(status / total_US_adults)

"""
Delete this line and write your answers to the question in step 2 here.
"""

south_adults = data_list[3][74:81]
total_south_adults = sum(south_adults)

total_south_status = []
for status in just_status:
    total_south_status.append(sum(status[74:81]))
percent_south_status = []
for status in total_south_status:
    percent_south_status.append(status / total_south_adults)
Reply
#2
And your work so far, and what specific questions you have, what errors you are getting?
Reply
#3
I'm trying to understand the the find relevant information question and answer the store what you need question.
Reply
#4
Please read this Homework and No Effort Questions
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I am completely lost on this homework assignment a36 1 2,447 Feb-21-2022, 06:01 AM
Last Post: buran
  I got lost in the program Gadev 1 2,415 Nov-11-2018, 05:50 PM
Last Post: j.crater
  I keep getting errors and I'm lost! samjonsnell 9 6,779 Oct-28-2018, 11:38 PM
Last Post: samjonsnell
  test..and I'm already lost sannixinc 1 2,991 Feb-22-2018, 09:09 PM
Last Post: glidecode
  Completly lost about to fail my class! crakacheezy 7 6,213 Dec-28-2017, 11:50 PM
Last Post: mepyyeti

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020