0

I have the following dataframe. lets call it df:

|Account  |Type   |Date        | Per   | Value|
-----------------------------------------------
|A        |FC     |31/03/2019  |3M     |a     |
|A        |FC     |30/06/2019  |3M     |b     |
|A        |FC     |30/09/2019  |3M     |c     |
|A        |FC     |31/12/2019  |3M     |d     |
|B        |P&G    |31/03/2019  |3M     |e     |
|B        |P&G    |30/06/2019  |3M     |f     |
|B        |P&G    |30/09/2019  |3M     |g     |
|B        |P&G    |31/12/2019  |3M     |h     |

Where a,bc,d,e,f,g,h are numerical values.For each element of the account column I need to keep the last value of the column that are in the same year, according to the date column, getting something like this:

|Account  |Type   |Date        | Per   | Value  |
-------------------------------------------------
|A        |FC     |31/12/2019  |3M     |d       |
|B        |P&G    |30/12/2019  |3M     |h       |

Where the value of the date column of the resulting dataframe corresponds to the last period that was added.

Can you guys help me?

Valeria Arango
  • 287
  • 1
  • 2
  • 8

0 Answers0