Questions tagged [datetime64]

NumPy array datatype with native support for datetime functionality

Since NumPy 1.7.0, the dtypes datetime64 and timedelta64 provide support for array types for datetime and timedelta functionality, respectively. Use this tag for questions specifically relating to these dtypes.

For more information, refer to the NumPy manual.

101 questions
0
votes
1 answer

What is the maximum timestamp numpy.datetime64 can handle?

I'm trying to convert datetime to numpy.datetime64 but the following case fails: >>> import numpy as np >>> from datetime import datetime >>> np.datetime64(datetime.max) OSError: Failed to use 'localtime_s' to convert to a local time I presume that…
mchen
  • 9,808
  • 17
  • 72
  • 125
0
votes
2 answers

grouping by weekly break down of datetimes 64 python

I have a pandas data frame with a column that represents dates as: Name: ts_placed, Length: 13631, dtype: datetime64[ns] It looks like this: 0 2014-10-18 16:53:00 1 2014-10-27 11:57:00 2 2014-10-27 11:57:00 3 2014-10-08 16:35:00 4 …
Blue Moon
  • 4,421
  • 20
  • 52
  • 91
0
votes
3 answers

Specifying a specific date value in python pandas dataframe

I have a dataframe df, with two columns, GROUP_ID={A,B} and ACTION_DATE. What I want to do is to replace the ACTION_DATE value to 03/31/2006, if the GROUP_ID's value is B. Data type of ACTION_DATE is datetime64[ns]. So, I tried the…
DavidH
  • 619
  • 2
  • 8
  • 15
0
votes
1 answer

Converting string to Numpy datetime

I'm using numpy 1.8.2 and the following code results in the error below: import numpy as np data = [] data.append(['2015-01-03 05:00:00', 5, 5.01]) data.append(['2015-01-04 05:00:00', 7, 7.01]) data.append(['2015-01-05 05:00:00', 8,…
gstanley
  • 73
  • 2
  • 11
0
votes
0 answers

How long will datetime64 and timedelta64 remain experimental for?

The numpy manual for version 1.12 states on the topic of datetimes and timedeltas: Note The datetime API is experimental in 1.7.0, and may undergo changes in future versions of NumPy. NumPy 1.7.0 was apparently released in February 2013, version…
gerrit
  • 24,025
  • 17
  • 97
  • 170
0
votes
0 answers

pandas: subtracting datetime64 columns with duplicate indices causes alignment problems

I'm really scratching my head on this one. Apparently, if you have a data frame with duplicate indices, subtracting columns consisting of datetimes breaks alignment, whereas subtracting regular int columns does not. Does "subtraction" mean something…
firey.fox
  • 1
  • 1
-1
votes
2 answers

How can i get matplotlib to correctly format these datetime64 objects?

I'm trying to plot a horizontal bar chart in python of the following data: table Using the following code: import matplotlib.pyplot as plt plt.barh(subset['sources'], width=subset['repairDate'], left=subset['appearanceDate']) but the output gives…
Phil
  • 3
  • 3
-1
votes
2 answers

Convert datetime64 to seconds

I subtracted two datetime64 columns and got a column of results such as '00:20:32' and '00:08:21.' How do I then convert those datetime64 values to seconds?
lwu29
  • 111
  • 1
  • 6
-1
votes
1 answer

datetime64 comparison in dataframes

I am struggling with datetime64 comparisons in dataframes to update a column. lets say we have a dataframe 'df' with a 'date' column df.date.values[0] Out[128]: numpy.datetime64('2015-05-17T22:00:00.000000000+0800') i needed to drop the time and…
desmond
  • 1,853
  • 4
  • 21
  • 27
-2
votes
1 answer

Does the unit passed to the datetime64 data type in pandas do anything?

Does the unit passed to the datetime64 data type in pandas do anything? Consider this code: import pandas as pd v1 = pd.DataFrame({'Date':['2020-01-01']*1000}).astype({'Date':'datetime64'}) v2 =…
MYK
  • 1,988
  • 7
  • 30
-2
votes
1 answer

plotting problem with pandas and datetime64

I am trying to plot a df column vs a datetime64 column. it plots OK, with just one problem - the intervals between ticks are equally spaced, although the datetime64 data is NOT equally spaced. df.info Date ^GSPC Open ^GSPC High ^GSPC Low …
1 2 3 4 5 6
7