Skip to content

Commit eb0d6a5

Browse files
author
Jared Weed
committed
Update code to remove NaN values
1 parent 2d5c8ff commit eb0d6a5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Binary file not shown.

projects/titanic_survival_exploration/titanic_visualizations.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,19 @@ def survival_stats(data, outcomes, key, filters = []):
6464
# Apply filters to data
6565
for condition in filters:
6666
all_data = filter_data(all_data, condition)
67+
68+
# Create outcomes DataFrame
6769
all_data = all_data[[key, 'Survived']]
6870

6971
# Create plotting figure
7072
plt.figure(figsize=(8,6))
7173

7274
# 'Numerical' features
7375
if(key == 'Age' or key == 'Fare'):
74-
76+
77+
# Remove NaN values from Age data
78+
all_data = all_data[~np.isnan(all_data[key])]
79+
7580
# Divide the range of data into bins and count survival rates
7681
min_value = all_data[key].min()
7782
max_value = all_data[key].max()

0 commit comments

Comments
 (0)