0

I have a dataframe where I want to replace all values of 999999 with another column value, while leaving all other values alone. Here is an example of what I have now:

Account max val Biology Statistics
Bill 100 999999 200
Frank 150 150 999999
Wendy 90 999999 100

Here is what I want the dataframe to look like:

Account max val Biology Statistics
Bill 100 100 200
Frank 150 150 150
Wendy 90 90 100

Is there an efficient way to accomplish this?

Thanks in advance.

1

1 Answer 1

2

I will do

df = df.mask(df==999999).ffill(axis = 1)
  Account max val Biology Statistics
0    Bill     100     100      200.0
1   Frank     150   150.0      150.0
2   Wendy      90      90      100.0
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.