In NumPy to display all the dates for a particular month, we can do it with the help of NumPy.arrange() pass the first parameter the particular month and the second parameter the next month and the third parameter is the datatype datetime64[D]. It will return all the dates for the particular month.
Syntax: numpy.arrange([start, ] stop, [step, ] dtype=None)
Parameters:
start : Start of interval
stop : End of interval
Step : Spacing between values
dtype : The type of the output array. If dtype is not given, infer the data type from the other input arguments.
Returns:
arrange : ndarray
Example 1#:
Python3
import numpy as np
print (np.arrange( '2012-07' , '2020-08' ,
dtype = 'datetime64[D]' ))
|
Output:
[‘2012-07-01’ ‘2012-07-02’ ‘2012-07-03’ … ‘2020-07-29’ ‘2020-07-30’
‘2020-07-31’]
Example 2#:
Python3
import numpy as np
print (np.arrange( '2012-09' , '2020-10' ,
dtype = 'datetime64[D]' ))
|
Output:
[‘2012-09-01’ ‘2012-09-02’ ‘2012-09-03’ … ‘2020-09-28’ ‘2020-09-29’
‘2020-09-30’]
Example 3#:
Python3
import numpy as np
print (np.arrange( '2012-02' , '2020-03' ,
dtype = 'datetime64[D]' ))
|
Output:
[‘2012-02-01’ ‘2012-02-02’ ‘2012-02-03’ … ‘2020-02-27’ ‘2020-02-28’
‘2020-02-29’]
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!