Skip to content

fix: avoid RuntimeWarning in Intro to Programming Lesson 1 Ex 5 - #491

Merged
jplotts merged 1 commit into
Kaggle:masterfrom
benluo-maui:fix-intro-programming-ex5-warning
Sep 28, 2026
Merged

jplotts merged 1 commit into
Kaggle:masterfrom
benluo-maui:fix-intro-programming-ex5-warning

Conversation

@benluo-maui

Copy link
Copy Markdown
Contributor

When calculating minors using (titanic_data.Age < 18).sum(), comparing float NaNs against < 18 triggers RuntimeWarning: invalid value encountered in less.

Calling .dropna() before the comparison avoids comparing NaN values, eliminating the warning while preserving the exact output (113).

When calculating minors using (titanic_data.Age < 18).sum(), comparing
float NaNs against < 18 triggers RuntimeWarning: invalid value encountered in less.

Calling .dropna() before the comparison avoids comparing NaN values,
eliminating the warning while preserving the exact output (113).

Bug: http://b/439887971
@benluo-maui

Copy link
Copy Markdown
Contributor Author

@jplotts Please take a look.

@jplotts
jplotts self-requested a review September 28, 2026 22:05
@jplotts
jplotts merged commit e9ba66d into Kaggle:master Sep 28, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants