Course: INF-604: Data Analysis Lecturer: Sothea HAS, PhD
Objective: You have already seen some elements of Data Analysis in the course. In this lab, we will take our first step into working with the main element of Data Analysis, which is the dataset. By the end of this lab, you will be able to import data into a Jupyter Notebook and perform some data manipulation.
Imagine you want to start your own business, such as a coffee shop or a bookstore. What types of data do you think you need to gather to determine the potential success of your business? Here are some questions to help you think and answer this question:
What is your plan for the business?
What information might you need to collect? What is the size of the data?
Where do you think you can find this information?
What might go wrong with the collected data?
What step do we need to handle this problem?
Answer:
2. Importing Some Data
There are many online data sources that you can explore, and one of the most popular is Kaggle. In addition to datasets, Kaggle also hosts data competitions with prizes and offers courses to help you advance in data learning.
Here, we start our journey by exploring a dataset that you probably have heard its name before: Titanic. You can download it from Kaggle using the following codes.
# %pip install kagglehubimport kagglehub# Download latest versionpath = kagglehub.dataset_download("yasserh/titanic-dataset")# Pandas module allows you to import the dataimport pandas as pddata = pd.read_csv(path+'/Titanic-Dataset.csv')data.head()
PassengerId
Survived
Pclass
Name
Sex
Age
SibSp
Parch
Ticket
Fare
Cabin
Embarked
0
1
0
3
Braund, Mr. Owen Harris
male
22.0
1
0
A/5 21171
7.2500
NaN
S
1
2
1
1
Cumings, Mrs. John Bradley (Florence Briggs Th...
female
38.0
1
0
PC 17599
71.2833
C85
C
2
3
1
3
Heikkinen, Miss. Laina
female
26.0
0
0
STON/O2. 3101282
7.9250
NaN
S
3
4
1
1
Futrelle, Mrs. Jacques Heath (Lily May Peel)
female
35.0
1
0
113803
53.1000
C123
S
4
5
0
3
Allen, Mr. William Henry
male
35.0
0
0
373450
8.0500
NaN
S
2.1. Overview of the data
Answer the following questions:
A. How many rows and columns are there in this dataset?
B. Explain the meaning of each column.
C. Are there any missing values in this dataset? If so, how many rows contain at least one missing value?
What should you do with column Cabin?
How would you drop rows with at least one missing value?
# Let's find out!
2.2. Single information
D. How many male and female passengers were on the ship?
E. How many of them survived? How many didn’t?
F. How many passengers were younger than 3 years old? How many were older than 60 years old?
G. How many passengers embarked from the three ports?
C: Cherbourg, France.
Q: Queentown, Ireland.
S: Southampton, England.
H. How many passengers were in the 1st, 2nd and 3rd class?
# To do
2.3. Multiple information
I. How many 1st class passengers survived? How about 2nd and 3rd class?
J. How many female passengers survived? How many males did?
K. How many people from each embarkation port survived?