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
1
vote
1 answer

How can I convert from YYYY-MM-DD on datetime64 to MM-DD and plotting tips

I have a database from COVID that I'm playing with. I have info in the format YYYY-MM-DD and I'm plotting days vs. number of cases in a bar plot. In my graph, the days appear as months, but I want an axis with every 7 days. Should I convert my…
1
vote
2 answers

How to handle missing value datetime64[ns] dtype column for Python Pandas DataFrame?

If I have data something like this, a missing value in 'Date4' column, its a datetime64[ns] dtype. How to handle missing values in this type of situation? What if I want to fill it with most_frequent date, how can it be done for the dates? I have…
HiMesh NaGar
  • 105
  • 2
  • 12
1
vote
1 answer

Sublcassing Pandas DatetimeIndex

I am trying to create a custom datetime class in python to support a time series model. After reviewing some of the existing python libraries I found that the pandas DatetimeIndex class provides much of the functionality I am looking for, but I…
hydrophile
  • 21
  • 3
1
vote
2 answers

Converting pandas datetime to numpy datetime

A rather simple problem, that i can't seem to figure. Setup Given a datetime.date or pandas.datetime I am trying to offset some dates that inevitably will be converted via pandas.to_datetime into an object that fails when used with…
Oliver
  • 8,169
  • 3
  • 15
  • 37
1
vote
2 answers

Replace a single character in a Numpy list of strings

I have a Numpy array of datetime64 objects that I need to convert to a specific time format yyyy-mm-dd,HH:MM:SS.SSS Numpy has a function called datetime_as_string that outputs ISO8601 (yyyy-mm-ddTHH:MM:SS.SSS) time, which is extremely close to what…
jgrant
  • 1,273
  • 1
  • 14
  • 22
1
vote
1 answer

How to merge a list containing data and datetime64[ns] with a pandas dataframe with datetime64[ns] index

I want to read two columns S1_max and S2_max from a dataframe data. Wherever a value is present in the S1_max column I want to check that each S1_max is succeeded by a corresponding S2_max signal. If so I calculate the time delta between the S1_max…
Aleminco
  • 45
  • 5
1
vote
1 answer

Is there a way in numba to determine days and hours with a numpy datetime64 variable?

I am running a very large function on a very large file (30 gigs). Because python is slow, I decided to try implement this function in numba. After initial reading it seems as if numba is very archaic in terms of manipulation ability with datetime,…
1
vote
1 answer

Anomaly using numPy datetime64 to work with dates in a pandas Dataframe column

Cannot covert 'YYYY-MM' string to YYYY-MM datetime using datetime64 for data in pandas DataFrame. np.datetime64 works to convert date string(s) of 'YYYY-MM' to datetime when stored in a scalar or array, but not when same data is accessed via a…
max
  • 41
  • 1
  • 6
1
vote
2 answers

Calculate with different datetime formats, datetime and datetime64

I am trying to calculate the days between two dates: First Date: date = datetime.datetime.today() # {datetime} 2018-09-17 14:42:06.506541 Second date, extracted from a data frame: date2 = data_audit.loc[(data_audit.Audit == audit),…
Geo
  • 37
  • 7
1
vote
0 answers

ValueError: Data type datetime64[ns] not understood. Please report an error to the developers

I'm trying to convert a pandas df using df.to_stata. In the process I'm getting an error: ValueError: Data type datetime64[ns] not understood. Please report an error to the developers A generalized version of the script…
1
vote
2 answers

Convert pandas series cell to string and datetime object

I have sliced the pandas dataframe. end_date = df[-1:]['end'] type(end_date) Out[4]: pandas.core.series.Series end_date Out[3]: 48173 2017-09-20 04:47:59 Name: end, dtype: datetime64[ns] How to get rid of end_date's index value 48173…
user3225309
  • 1,183
  • 3
  • 15
  • 31
1
vote
2 answers

datetime64 error when adding to Pandas DataFrame

I have an issue with Python + Numpy + Pandas. I am having a list of timestamps, with millisecond accuracy, encoded as strings. Then I round them to 10ms resolution, that goes well. The bug comes when I add the rounded timestamps to DataFrame as a…
Girts Strazdins
  • 848
  • 9
  • 15
1
vote
1 answer

Odd timezone behavior using groupby/agg in pandas

I'm running into some odd behavior trying to group rows of a pandas dataframe by ID and then selecting out max/min datetimes (w/ timezones). This is with pandas 0.18.1 and numpy 1.11.1 (I saw in earlier posts a similar problem was apparently fixed…
1
vote
1 answer

Setting the day in a pandas frame column, from a string list containing only the hours

I wonder if anyone could please help me with this issue: I have a pandas data frame (generated from a text file) which should have a structure similar to this one: import pandas as pd data = {'Objtype' : ['bias', 'bias', 'flat', 'flat',…
Delosari
  • 677
  • 2
  • 17
  • 29
1
vote
1 answer

Problems with timezone in numpy.datetime64

I'm a bit confused how numpy handles timezones. If I create a datetime-object just with a date, it seems it uses Zulu-Timezone. If I use an additional timestep, it uses my current timezone. If I then manipulate these objects, e.g. add a timedelta,…
MichaelA
  • 1,866
  • 2
  • 23
  • 38