Home > Net >  Python: Generate weekly timestamps
Python: Generate weekly timestamps

Time:11-30

How can I generate weekly timestamps in Python?

I want something that looks like this:

2021-01-07 12:00:00
2021-01-14 12:00:00
2021-01-21 12:00:00
etc...

I also want to convert these to UNIX timestamps.

Is there a way to do all this in one step?

Thank you!

CodePudding user response:

Check https://pandas.pydata.org/docs/reference/api/pandas.date_range.html

pd.date_range('2021-01-07 12:00:00', '2021-01-21 12:00:00', freq='7D')
  • Related