base_date id
2022-07 A
2022-07 B
2022-08 A
2022-08 B
From this data frame type of data, I want to get base_date with the last date of the month.
Sample Results
base_date bade_date_day id
2022-07 2022-07-31 A
2022-07 2022-07-31 B
2022-08 2022-08-30 A
2022-08 2022-08-30 B
I'm not sure about Python or data frames, but the basic concept is simple. For example, to obtain the last day of 2022-02
:
In most languages, a date-time-time zone computable implementation of "1 month plus" or "1 day minus" is provided. For example, PHP has DateTime
, so:
$baseDate = new DateTime('2022-02-01');
$baseDateDay = $baseDate->modify('+1 month')->modify('-1 day');
Python might have something like this. Look it up and try it yourself!
© 2024 OneMinuteCode. All rights reserved.