I was wondering if there is a quick way, e.g. via quantlib or any other python package/module, to allocate or to correspond time to maturity day differences to standard tenor buckets. In other words, is there any already developed automation which would give me the following 1M and 2Y results after feeding it with the 21 and 567 figures, respectively?
reference_date maturity_date difference tenor
31-05-2024 21-06-2024 21 1M
31-05-2024 19-12-2025 567 2Y