Let's generate a df
with random numbers using code below.
test = pd.DataFrame(index=pd.date_range('2019-03-28', '2020-07-31'))
np.random.seed(101)
test['Value'] = np.random.rand(test.shape[0])*1000
If I resample on quarterly basis and get the last value the code to do that would be as follows:
test.resample('Q').last()
How can I get last value on semi-annual resample and financial year resample?
Expected Output - Semi-Annual
+------------+-------------+
| Date | Value |
+------------+-------------+
| 30/06/2019 | 13.24101109 |
| 31/12/2019 | 67.13832944 |
| 30/06/2020 | 757.1984631 |
+------------+-------------+
Expected Output - Financial Year
+------------+-------------+
| Date | Value |
+------------+-------------+
| 30/06/2019 | 13.24101109 |
| 30/06/2020 | 757.1984631 |
+------------+-------------+