0

How should I do to divide years in half a year in this case if running in Python code?

The start year is 2020-05-15 and the final year is 2030-05-15.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • What is half a year? – Sri May 25 '20 at 19:44
  • https://docs.python.org/3/library/datetime.html#timedelta-objects ? – wwii May 25 '20 at 19:46
  • I mean divide the whole years by 6 months – Jiang Yunke May 25 '20 at 19:46
  • 1
    Not clear what you are having a problem with. Please read [mre]. .. Please don't post images of code, data, or Tracebacks. Copy and paste it as text then format it as code (select it and type `ctrl-k`) ... [Discourage screenshots of code and/or errors](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors) – wwii May 25 '20 at 19:47
  • Sorry for the misunderstanding. Briefly, if the year starts from 2020-01-01 to 2021-12-31, what I want to do is to divide it into four time periods and list them as dataframes. Are there any functions can do that in Python? – Jiang Yunke May 25 '20 at 19:58

1 Answers1

1

enter image description here enter image description here

I wasn't sure if you wanted horizontal or vertical divisions so I gave you both.

More practically, maybe this answer will help? Creating numpy linspace out of datetime

You can specify start and end date and the number of divisions.

Alex
  • 947
  • 6
  • 16