• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to replace by np.nan elements outside a range of float numbers in a row in pandas?

Resolved: How to replace by np.nan elements outside a range of float numbers in a row in pandas?

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a dataframe:
I need to replace by np.nan all elements in the row that are outside the limits of mean+3std and mean-3std. In other words, values less than mean-3std, and values higher than mean+3std, should be replaced by np.nan.
I am just putting one column of my dataframe, but I actually have eleven columns where all values outside the specific column range must be replaced by np.nan. All in place within the original df.
Is there a simple way of doing this? I have tried to use lambda functions with where, but it doesn’t work.

Answer:

Use DataFrame.mask

If you have better answer, please add a comment about this, thank you!

dataframe pandas python python-3.x
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How can I modify formData before sending it?

01/04/2023

Resolved: How to efficient create SimpleITK image?

01/04/2023

Resolved: How can I write CSS selector(s) that apply to table rows for all td elements on that row after a td with a certain class?

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.