0

Please advise on how to select the second max date in df rows.

I have a df like this:

ID   Count   DDate1  DDate2 DDate3 DDate4 DDate5

Columns with ddate are converted to datetime. The max value I have found in this way:

cols_1 = df_deal_employee.columns[2:6]
df['max_date'] = df[cols_1].max(1)

But can I create a column with the following max date? (second largest).

  • What do you mean by "following max date"? The date that comes immediately after the max date? –  Dec 14 '21 at 00:17
  • @user17242583 Exactly, the following date after max date. – JeSuisVictoria Dec 14 '21 at 00:31
  • And you want all the rows of that column to be that same date? Because assigning a single value to a column causes all the rows of that column to be the value. –  Dec 14 '21 at 00:33
  • @user17242583 I have various columns, so a new column should show the second largest date for EACH row. – JeSuisVictoria Dec 14 '21 at 00:35

0 Answers0