Pandas DataFrame: update all values in all columns, based on condition

Question:

Check all column’s values. If the value is greater than 100,000:

-> Subtract 4294967295 and then add 1 to it.

I did it, but for one column like this:

df.loc[df['12:00AM'] > 100000, '12:00AM'] = (4294967295 - df.loc[df['12:00AM'] > 100000, '12:00AM']) +1

I want to apply this code for all columns.

Asked By: Hisham

||

Answers:

I did it like this: where : A-B = -B+A

df[df> 100000] = -1*df[df> 100000] + 4294967295+1
Answered By: Hisham
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.