Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

3/23/23, 3:34 PM Untitled10.

ipynb - Colaboratory

import pandas as pd

df = pd.read_csv("/content/Book3.csv")

df

Number Age Gender Nationality Program Course English Academic Atten

Social
31- Sciences
0 1 M Korea PM 60%~70% NaN
35 and
Humanities

Science
26-
1 2 M China PM and 60%~70% 50%~59%
30
engineering

26-
2 3 M Kenya PM Business 60%~70% NaN
30

21- Law/Legal
3 4 M Vietnam PM 60%~70% 60%~70%
25 studies

21-
4 5 M China PM Business 60%~70% 50%~59%
25

... ... ... ... ... ... ... ... ...

21-
120 121 M China PM Business 60%~70% 50%~59%
25

df.head(5)

Number Age Gender Nationality Course Academic

0 1 31-35 M Korea Social Sciences and Humanities >70%

1 2 26-30 M China Science and engineering 50%~59%

2 3 26-30 M Kenya Business NaN

3 4 21-25 M Vietnam Law/Legal studies 60%~70%

4 5 21-25 M China Business 50%~59%

df.tail()

Number Age Gender Nationality Program Course English Academic Attendance

120 121 21-25 M China PM Business 60%~70% 50%~59% S1

121 122 31-35 F China PM Business 50%~59% 50%~59% S1

122 123 26-30 M Gongo PM Business >70% 60%~70% S0

123 124 21-25 F Ukraine PM Business 60%~70% 60%~70% S1

124 125 26-30 F Korea PM Business 60%~70% >70% S0

df.describe()

Number

count 125.000000

mean 63.000000

std 36.228442

min 1.000000

25% 32.000000

50% 63.000000

75% 94.000000

max 125.000000

df.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 125 entries, 0 to 124
Data columns (total 9 columns):

https://colab.research.google.com/drive/1Yo23NDblZGNiRaTBLTeB8e150f5vp1JP#scrollTo=k8tmEXThoAiw&printMode=true 1/3
3/23/23, 3:34 PM Untitled10.ipynb - Colaboratory
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Number 125 non-null int64
1 Age 125 non-null object
2 Gender 125 non-null object
3 Nationality 125 non-null object
4 Program 125 non-null object
5 Course 125 non-null object
6 English 119 non-null object
7 Academic 103 non-null object
8 Attendance 119 non-null object
dtypes: int64(1), object(8)
memory usage: 8.9+ KB

df.isnull()

Number Age Gender Nationality Program Course English Academic Attendance

0 False False False False False False False True False

1 False False False False False False False False False

2 False False False False False False False True False

3 False False False False False False False False False

4 False False False False False False False False False

... ... ... ... ... ... ... ... ... ...

120 False False False False False False False False False

121 False False False False False False False False False

122 False False False False False False False False False

123 False False False False False False False False False

124 False False False False False False False False False

125 rows × 9 columns

df.isnull().sum()

Number 0
Age 0
Gender 0
Nationality 0
Program 0
Course 0
English 6
Academic 22
Attendance 6
dtype: int64

df.dtypes

Number int64
Age object
Gender object
Nationality object
Program object
Course object
English object
Academic object
Attendance object
dtype: object

df.shape

(125, 9)

df.ndim

df['Gender'].replace(['M', 'F'],
                        [0, 1], inplace=True)

df

https://colab.research.google.com/drive/1Yo23NDblZGNiRaTBLTeB8e150f5vp1JP#scrollTo=k8tmEXThoAiw&printMode=true 2/3
3/23/23, 3:34 PM Untitled10.ipynb - Colaboratory

Number Age Gender Nationality Program Course English Academic Attendance

31- Social Sciences and


0 1 0 Korea PM 60%~70% NaN S0
35 Humanities

26-
1 2 0 China PM Science and engineering 60%~70% 50%~59% S3
30

26-
2 3 0 Kenya PM Business 60%~70% NaN S0
30

21-
3 4 0 Vietnam PM Law/Legal studies 60%~70% 60%~70% S0
25

21-
4 5 0 China PM Business 60%~70% 50%~59% S1
25

... ... ... ... ... ... ... ... ... ...

21-
120 121 0 China PM Business 60%~70% 50%~59% S1
25

31-
121 122 1 China PM Business 50%~59% 50%~59% S1
new_df = df.dropna() 35

26
new_df

Number Age Gender Nationality Program Course English Academic Attendance

26- Science and


1 2 0 China PM 60%~70% 50%~59% S3
30 engineering

21-
3 4 0 Vietnam PM Law/Legal studies 60%~70% 60%~70% S0
25

21-
4 5 0 China PM Business 60%~70% 50%~59% S1
25

21-
5 6 0 China PM Law/Legal studies 60%~70% 60%~70% S0
25

21-
6 7 0 China PM Art and Design 60%~70% 60%~70% S0
25

... ... ... ... ... ... ... ... ... ...

21-
120 121 0 China PM Business 60%~70% 50%~59% S1
25

31-
121 122 1 China PM Business 50%~59% 50%~59% S1
35

26

Colab paid products - Cancel contracts here

https://colab.research.google.com/drive/1Yo23NDblZGNiRaTBLTeB8e150f5vp1JP#scrollTo=k8tmEXThoAiw&printMode=true 3/3

You might also like