Skip to content

Instantly share code, notes, and snippets.

@okdolly-001
Created March 17, 2018 21:23
Show Gist options
  • Select an option

  • Save okdolly-001/3c1a191f32733a9b69345b6773d330f5 to your computer and use it in GitHub Desktop.

Select an option

Save okdolly-001/3c1a191f32733a9b69345b6773d330f5 to your computer and use it in GitHub Desktop.
Check Nan and infinity in pandas and Numpy #np #pandas
1. Check if all elements in pandas/numpy are finite. notnull = isfinite
Pandas:
X_train.notnull().values.all()
np.isfinite(X_train).all()
2. Check if any elements in Pandas is Na.
Pandas:
X_train.isnull().values.any()
np.isnan(X_train).any()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment