'Generate Last Day of Quarter from Quarter Number and Year
I have a pandas Data Frame containing column Quarter and Year. I want to create the column Date where date would be the last date of that quarter.
Create a dummy data frame using code below:
data = {'year':[2021, 2022, 2023, 2024],
'quarter':[1, 2, 3, 4]}
df = pd.DataFrame(data)
Expected Output
+------+---------+------------+
| year | quarter | Date |
+------+---------+------------+
| 2021 | 1 | 2021-03-31 |
| 2022 | 2 | 2022-06-30 |
| 2023 | 3 | 2023-09-30 |
| 2024 | 4 | 2024-12-31 |
+------+---------+------------+
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
