If I have a custom list of days like the one below (but it can any arbitrary days):
from datetime import datetime, timedelta
base = datetime.today()
date_list = [base - timedelta(days=x) for x in range(0, 1000)]
How can I extract the first date of each month/year from the list and separately extract the last date of the list?
One way I was thinking of doing this was if I have my list in a pandas.Series
then group the dates in their respective month/year and then look at the days of each date and take the lowest (for the first date) and highest day (for the last date).
I just don't know how to do that.
To be clear: I am trying to find the first / last day of the month inside a custom list. For example if I have only 15 Feb 2018 inside my list. This will be both the first and last day of the month for my list.