0

I have a dataframe as below:

                F_Time        BP     BQ  BO0  BO1  BO2  BO3  BO4
0  2020-07-10 09:30:00  10780.00   8550    1   28    1    1    2
1  2020-07-10 10:15:00  10788.00   8700    1    5   10    2    1
2  2020-07-10 10:20:00  10780.00  12150    1    1    1    3   76
3  2020-07-10 10:30:00  10770.00  15675    3    2    8    4   94
4  2020-07-10 10:35:00  10760.60   8100    2    1    1    1   29
5  2020-07-10 10:40:00  10750.00  18825    8    9  154    1    1
6  2020-07-10 11:05:00  10725.00   9825    3    4   94    1    1

I want to find the Max Value from group of Column Values (BO0, BO1, BO2, BO3, BO4) for every row:

Expected Output as below:

                F_Time        BP     BQ    BO
0  2020-07-10 09:30:00  10780.00   8550    28
1  2020-07-10 10:15:00  10788.00   8700    10
2  2020-07-10 10:20:00  10780.00  12150    76
3  2020-07-10 10:30:00  10770.00  15675    94
4  2020-07-10 10:35:00  10760.60   8100    29
5  2020-07-10 10:40:00  10750.00  18825   154
6  2020-07-10 11:05:00  10725.00   9825    94
Rohit Lamba K
  • 510
  • 1
  • 4
  • 11
  • https://stackoverflow.com/questions/12169170/find-the-max-of-two-or-more-columns-with-pandas – wwii Jul 12 '20 at 03:49

1 Answers1

2

Try this.

df["BO"] = df[["BO0", "BO1".....]].max(axis=1)
Sonu
  • 314
  • 2
  • 9