How should I do to divide years in half a year in this case if running in Python code?
Asked
Active
Viewed 538 times
0

wjandrea
- 28,235
- 9
- 60
- 81

Jiang Yunke
- 23
- 5
-
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
-
1Not 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 Answers
1
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