Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python assigment using pandas library The data stored in the file passangers.csv contains the passenger information of the ship Titanic, sunk in 1912. In the

Python assigment using pandas library

The data stored in the file passangers.csv contains the passenger information of the ship "Titanic", sunk in 1912. In the file, each row refers to a particular passenger on the Titanic. The columns give you specific information about each passenger. The information in the columns are as follow:

1. PassengerId: identifier given to each passenger in the data set

2. Survived: Indicates whether the passenger survived the sinking (0=died)

3. Pclass: Indicates the socio-economic status of the passenger (lower number means higher class)

4. Name: The passenger's name

5. Sex: The passenger's sex

6. Age: The passenger's age

7. SibSp: The number of siblings / spouses the passenger was traveling with

8. Parch: The number of children / parents the passenger was traveling with

9. Ticket: The passenger's ticket number

10. Fare: How much the passenger paid for their ticket

11. Embarked: The passenger's port of embarkation (C = Cherbourg, Q = Queenstown, S = Southampton) Load the data into Dataframe using the read_csv( ) function. For example: df = pd.read_csv(passangers.csv )

Write a code to answer the following questions:

a. Determine how many people died.

b. Determine from the survivors, how many were from 1,2 class.

c. Determine how many men and how many women survived the disaster

d. Determine how many children at or under the age of 15 survived the disaster, and how many children were present total.

e. The SibSp and Parch attributes tell us the number of siblings/spouses and parents/children each passenger had on board. Create a new column in the DataFrame called Family that indicates how many siblings/spouses/parents/children a passenger was traveling with. Then report how many people survived that were traveling with 3 or more family members

passangers.csv

PassengerId,Survived,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Embarked

1,0,3,"Braund, Mr. Owen Harris",male,22.0,1,0,A/5 21171,7.25,S

2,1,1,"Cumings, Mrs. John Bradley (Florence Briggs Thayer)",female,38.0,1,0,PC 17599,71.2833,C

3,1,3,"Heikkinen, Miss. Laina",female,26.0,0,0,STON/O2. 3101282,7.925,S

4,1,1,"Futrelle, Mrs. Jacques Heath (Lily May Peel)",female,35.0,1,0,113803,53.1,S

5,0,3,"Allen, Mr. William Henry",male,35.0,0,0,373450,8.05,S

7,0,1,"McCarthy, Mr. Timothy J",male,54.0,0,0,17463,51.8625,S

8,0,3,"Palsson, Master. Gosta Leonard",male,2.0,3,1,349909,21.075,S

9,1,3,"Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg)",female,27.0,0,2,347742,11.1333,S

10,1,2,"Nasser, Mrs. Nicholas (Adele Achem)",female,14.0,1,0,237736,30.0708,C

11,1,3,"Sandstrom, Miss. Marguerite Rut",female,4.0,1,1,PP 9549,16.7,S

12,1,1,"Bonnell, Miss. Elizabeth",female,58.0,0,0,113783,26.55,S

13,0,3,"Saundercock, Mr. William Henry",male,20.0,0,0,A/5. 2151,8.05,S

14,0,3,"Andersson, Mr. Anders Johan",male,39.0,1,5,347082,31.275,S

15,0,3,"Vestrom, Miss. Hulda Amanda Adolfina",female,14.0,0,0,350406,7.8542,S

16,1,2,"Hewlett, Mrs. (Mary D Kingcome) ",female,55.0,0,0,248706,16.0,S

17,0,3,"Rice, Master. Eugene",male,2.0,4,1,382652,29.125,Q

19,0,3,"Vander Planke, Mrs. Julius (Emelia Maria Vandemoortele)",female,31.0,1,0,345763,18.0,S

21,0,2,"Fynney, Mr. Joseph J",male,35.0,0,0,239865,26.0,S

22,1,2,"Beesley, Mr. Lawrence",male,34.0,0,0,248698,13.0,S

23,1,3,"McGowan, Miss. Anna ""Annie""",female,15.0,0,0,330923,8.0292,Q

24,1,1,"Sloper, Mr. William Thompson",male,28.0,0,0,113788,35.5,S

25,0,3,"Palsson, Miss. Torborg Danira",female,8.0,3,1,349909,21.075,S

26,1,3,"Asplund, Mrs. Carl Oscar (Selma Augusta Emilia Johansson)",female,38.0,1,5,347077,31.3875,S

28,0,1,"Fortune, Mr. Charles Alexander",male,19.0,3,2,19950,263.0,S

31,0,1,"Uruchurtu, Don. Manuel E",male,40.0,0,0,PC 17601,27.7208,C

34,0,2,"Wheadon, Mr. Edward H",male,66.0,0,0,C.A. 24579,10.5,S

35,0,1,"Meyer, Mr. Edgar Joseph",male,28.0,1,0,PC 17604,82.1708,C

36,0,1,"Holverson, Mr. Alexander Oskar",male,42.0,1,0,113789,52.0,S

38,0,3,"Cann, Mr. Ernest Charles",male,21.0,0,0,A./5. 2152,8.05,S

39,0,3,"Vander Planke, Miss. Augusta Maria",female,18.0,2,0,345764,18.0,S

40,1,3,"Nicola-Yarred, Miss. Jamila",female,14.0,1,0,2651,11.2417,C

41,0,3,"Ahlin, Mrs. Johan (Johanna Persdotter Larsson)",female,40.0,1,0,7546,9.475,S

42,0,2,"Turpin, Mrs. William John Robert (Dorothy Ann Wonnacott)",female,27.0,1,0,11668,21.0,S

44,1,2,"Laroche, Miss. Simonne Marie Anne Andree",female,3.0,1,2,SC/Paris 2123,41.5792,C

45,1,3,"Devaney, Miss. Margaret Delia",female,19.0,0,0,330958,7.8792,Q

50,0,3,"Arnold-Franchi, Mrs. Josef (Josefine Franchi)",female,18.0,1,0,349237,17.8,S

51,0,3,"Panula, Master. Juha Niilo",male,7.0,4,1,3101295,39.6875,S

52,0,3,"Nosworthy, Mr. Richard Cater",male,21.0,0,0,A/4. 39886,7.8,S

53,1,1,"Harper, Mrs. Henry Sleeper (Myna Haxtun)",female,49.0,1,0,PC 17572,76.7292,C

54,1,2,"Faunthorpe, Mrs. Lizzie (Elizabeth Anne Wilkinson)",female,29.0,1,0,2926,26.0,S

55,0,1,"Ostby, Mr. Engelhart Cornelius",male,65.0,0,1,113509,61.9792,C

57,1,2,"Rugg, Miss. Emily",female,21.0,0,0,C.A. 31026,10.5,S

58,0,3,"Novel, Mr. Mansouer",male,28.5,0,0,2697,7.2292,C

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

Make efficient use of your practice time?

Answered: 1 week ago