Python | numpy.datetime64() method
With the help of numpy.datetime64() method, we can get the date in a numpy array in a particular format i.e year-month-day by using numpy.datetime64() method.
Syntax :
numpy.datetime64(date)
Return : Return the date in a format ‘yyyy-mm-dd’.
Example #1 :
In this example we can see that by using numpy.datetime64() method, we are able to get the date in the particular format i.e yyyy-mm-dd.
# import numpy import numpy as np # using numpy.datetime64() method gfg = np.array(np.datetime64('2019-08-26')) print(gfg) |
Output :
array(‘2019-08-26′, dtype=’datetime64[D]’)
Example #2 :
# import numpy import numpy as np # using numpy.datetime64() method gfg = np.array(np.datetime64('2019-08', 'D')) print(gfg) |
Output :
array(‘2019-08-01′, dtype=’datetime64[D]’)
Recommended Posts:
- class method vs static method in Python
- Python | next() method
- Python | os.dup() method
- Python | set() method
- Python | os.closerange() method
- Python PIL | tobytes() Method
- Python | sympy.sin() method
- Python PIL | getpalette() Method
- Python | sympy.nP() method
- Python | os.close() method
- Python | sympy.nC() method
- Python | os.fstat() method
- Python | os.fchdir() method
- Python | os.chdir() method
- Python | os.dup2() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



