<jupyter_start><jupyter_text>Problem StatementHello!You have been hired by **'CACT'(Census Analysis and Collection Team)** to help with your numpy programming skills. Your major work for today involves census record management and data analysis.About the DatasetThe snapshot of the data, you will be working on:The dataset has details of 100 people with the following 8 features Why solve this projectAfter completing this project, you will have a better grip on working with numpy. In this project, you will apply the following concepts:- Array Appending- Array Slicing- Array Filtering- Array Aggregation<jupyter_code># Importing important libraries
import numpy as np
# File path
path = "file.csv"
#Reading file
data = np.genfromtxt(path, delimiter=",", skip_header=1)
data
#New record
new_record=[[50,  9,  4,  1,  0,  0, 40,  0]]
new_record_arr = np.array(new_record)
census = np.concatenate((data, new_record_arr), axis = 0)
data.shape, census.shape, census
# Creating a new array 'age' by taking only age values from census
age = census[0:,0]
age
# Find the maximum age in the array 'age'
max_age = np.amax(age)
max_age
# Find the minimum age in the array 'age'
min_age = np.amin(age)
min_age
# Find the mean age and the standard deviation in age.
age_mean = np.mean(age)
age_mean
age_std = np.std(age)
age_std
# Subsetting the different races to specific arrays
race_0 = np.array([])
race_1 = np.array([])
race_2 = np.array([])
race_3 = np.array([])
race_4 = np.array([])

for r in census[0:,2]:
    if(r==0):
        race_0 = np.append(race_0, r)
    elif(r==1):
        race_1 = np.append(race_1, r)
    elif(r==2):
        race_2 = np.append(race_2, r)
    elif(r==3):
        race_3 = np.append(race_3, r)
    elif(r==4):
        race_4 = np.append(race_4, r)
race_1
len_0 = len(race_0)
len_1 = len(race_1)
len_2 = len(race_2)
len_3 = len(race_3)
len_4 = len(race_4)
len_3
# Finding out the minority race ( race with minimum no. of citizens )
race_count = list([len_0, len_1, len_2, len_3, len_4])
race_count
minority_race = race_count.index(min(race_count))
minority_race
# STEP - 4

senior_citizens = census[census[0:,0] > 60]
senior_citizens
working_hours_sum = sum(senior_citizens[0:,6])
working_hours_sum
avg_working_hours = working_hours_sum / len(senior_citizens)
avg_working_hours
len(senior_citizens)
# STEP 5 - 
# Creating 'high' and 'low' subsets for people with education-num greater than 
# & lower than equal to 10 respectively.
high = census[census[0:,1] > 10]
low = census[census[0:,1] <= 10]
# Calculating mean of income for both the subsets
avg_pay_high = round(sum(high[0:,7])/len(high), 2)
avg_pay_low = round(sum(low[0:,7])/len(low), 2)
avg_pay_low<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup