1

Given a Pandas DataFrame, I'm trying to delete columns that contain any row values greater than or equal to 109 and row values less than or equal to 10-9.

What would be the best method to perform such an action?

Note: I have NaN types in the DataFrame, which I would like to keep, i.e. the code has to work with NaN types.

1 Answer 1

1

If you really must keep those values NaN, you could first fill them in with a placeholder, then remove the placeholder after filtering.

df.fillna('None placeholder', inplace=True)
df = df[(df > 10**(-9)) & (df < 10**9)].dropna(axis=1)
df.replace('None placeholder', np.nan, inplace=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.