Creating a range of dates in Python

+1 vote
Is it possible to create a return a range of dates in python?
Jul 4 in Python by Nisa
• 1,090 points

retagged Jul 5 by Kalgi 28 views

1 answer to this question.

+1 vote

Yes, you can do it as follows:

import pandas as pd
dates = pd.date_range(pd.datetime.today(), periods=5).tolist()
dates

OUTPUT:

[Timestamp('2019-07-04 16:21:27.028459', freq='D'),
 Timestamp('2019-07-05 16:21:27.028459', freq='D'),
 Timestamp('2019-07-06 16:21:27.028459', freq='D'),
 Timestamp('2019-07-07 16:21:27.028459', freq='D'),
 Timestamp('2019-07-08 16:21:27.028459', freq='D')]
answered Jul 4 by Wajiha
• 1,920 points

Related Questions In Python

0 votes
2 answers
+1 vote
4 answers

Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

answered Oct 18, 2018 in Python by tinitales
1,118 views
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
733 views
0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2 in Python by anonymous
212 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 283 views
+4 votes
6 answers
0 votes
1 answer

Slicing a list using a variable, in Python

Yes its possible. Use the following piece ...READ MORE

answered Jul 2 in Python by Wajiha
• 1,920 points
24 views
0 votes
1 answer

flush parameter of print in Python

Usually all I/Os are buffered, meaning they ...READ MORE

answered Jul 30 in Python by Wajiha
• 1,920 points
24 views