-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise3_1016.py
More file actions
42 lines (31 loc) · 1.09 KB
/
exercise3_1016.py
File metadata and controls
42 lines (31 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from datasets import load_dataset
import pandas as pd
dataset = load_dataset('mstz/titanic')
df = pd.DataFrame(dataset['train'])
def get_passenger_count():
# return the number of passengers in the dataset
pass
def get_median_age():
# return the median age of the passengers
pass
def get_gender_count():
# count the number of male and female passengers
return len(df[df['is_male'] == True])
def fill_nan_age_with_mean():
# fill NaN age values with mean age
pass
def sort_by_family_name():
# Make family members are near eachother in the dataframe.
# This is done by sorting the dataframe by the 'name' column.
pass
def find_lowest_fare_pclass1():
# Find the lowest fare for passengers in the first class cabin.
# This is determined by finding the lowest 'Fare' value in the 'Pclass' column where Pclass equals 1.
pass
if __name__ == '__main__':
print(get_passenger_count())
print(get_median_age())
print(get_gender_count())
print(fill_nan_age_with_mean())
print(sort_by_family_name())
print(find_lowest_fare_pclass1())