Creating a range of dates in Python

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

retagged Jul 5, 2019 by Kalgi 1,407 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, 2019 by Wajiha
• 1,960 points

Related Questions In Python

–1 vote
2 answers
+1 vote
8 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
35,864 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
3,413 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, 2019 in Python by anonymous
5,764 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,358 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,926 views
0 votes
1 answer

Slicing a list using a variable, in Python

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

answered Jul 2, 2019 in Python by Wajiha
• 1,960 points
1,970 views
0 votes
1 answer

flush parameter of print in Python

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

answered Jul 30, 2019 in Python by Wajiha
• 1,960 points
7,092 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP