Question: Input the following data into a data frame called titanic, and display the entire data frame: Sex, Class, Survived, Died Children, First, 6, 0 Children,
- Input the following data into a data frame called titanic, and display the entire data frame:
Sex, Class, Survived, Died
Children, First, 6, 0
Children, Second, 24, 0
Children, Third, 27, 52
Men, First, 57, 118
Men, Second, 14, 154
Men, Third, 75, 387
Men, Crew, 192, 693
Women, First, 140, 4
Women, Second, 80, 13
Women, Third, 76, 89
Women, Crew, 20, 3
- Using Boolean Indexing (See hereLinks to an external site.), show the data of the people in first class.
- Delete the crew members from the data (use Boolean indexing).
- Create a new column that is the total number of people for that group (those who survived + died. Use Boolean Indexing in conjunction with selection of non-existent column).
- Create a new column with the percentage of people who survived.
- Delete the column indicating the total number of people in that group.
- Only show the rows where more than 80% of the people survived.
- Then only show the rows where less than 40% of the people survived.
- Calculate the total number of people that survived and died for each class, then report the percentages. (Hint: Use a grouped calculation.)
- Save your table in CSV format (as e.g. titanic_data.csv) with the first line as headers for the columns (see examples: hereLinks to an external site.)
- Duplicate the CSV file on your computer since you will be editing the copied version (e.g. titanic_data2.csv). Open the new CSV file in a text editor. Note the way the data is organized. Now, in the text editor, add new lines including the data for the crew that was removed earlier. (Help: the percentage of male crew and female crew that survived was 21.69% and 86.96%.)
- Now read that updated CSV file into a new data frame called titanic2, and display the data.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
