This is my DataFrame df
:
col1 col2
-0.441406 2.523047
-0.321105 1.555589
-0.412857 2.223047
-0.356610 2.513048
When I check df
, I see that there are some infinite values.
np.any(np.isnan(df))
np.all(np.isfinite(df))
False
True
What is the difference between NaN and infinite? Also, how can I delete all infinite values to get True in np.all(np.isfinite(X))
?
This is what I tried:
df = df.replace([np.inf, -np.inf], np.nan).dropna(how="all")
But still the check of infinite
gives me True.
Moreover, .apply(lambda s: s[np.isfinite(s)].dropna()).count()
gives me the same number of rows of all columns as simply df.shape
, which indicates the lack of infinite values. But in this case why np.all(np.isfinite(df))
returns True?