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

data.sort_values(by=['Date'], ascending=False) doesn't works

I need to plot some data series in x axis and I have a csv file which "Start time" colum is full of dates. As I work with DataFrame, I use pandas library to manipulate the data. My datetime data is: Input: print(paradas["Start time"]) …
0
votes
1 answer

How do I convert numpy array to days, hours, mins?

Running with this series X = number_of_logons_all.values split = round(len(X) / 2) X1, X2 = X[0:split], X[split:] mean1, mean2 = X1.mean(), X2.mean() var1, var2 = X1.var(), X2.var() print('mean1=%f, mean2=%f' % (mean1, mean2)) print('variance1=%f,…
0
votes
2 answers

Fetching particular rows of a csv file where date matches as entered by user?

enter image description herei have a csv file like Slot object Name object Plate object Date_of_reg datetime64[ns] dtype: object I was working on a parking program that can give person data…
0
votes
1 answer

Numpy datetime64 time units - conversion from string with more than 4 year digits

I was playing around with extreme values for dates and realized a strange behaviour: # 1. normal date in nanoseconds print(np.datetime64('2020-04-14T00:00:00.000000', 'ns')) # 2. extreme year date in…
Antje Janosch
  • 1,154
  • 5
  • 19
  • 37
0
votes
1 answer

"Check for duplicates" error when I am trying to sort dataframe by datetime64

I am trying to sort a dataframe by date like this : result = result.sort_values(by=result.CF_FACT_DATFACT, ascending=True) CF_FACT_DATFACT is a datetime64. by executing this command I have this error : KeyError …
el abed houssem
  • 350
  • 1
  • 7
  • 16
0
votes
1 answer

How do I convert a pandas column of datetime64 objects to the year?

I'm working with a pandas dataframe in which one column is a datetime64 object. I need to plot a bar chart of the number of rows per year, and also slice the dataframe for a month range (e.g. January 2011 to March 2011). I suppose I could add a…
Ryan Chng
  • 117
  • 4
  • 10
0
votes
1 answer

Why can't merge datetime64 with ohter arrays with np.c_?

I'm migrating from Matlab... Using Jupyter Lab in Windows 10. Let's say I have a time series, with an array of datetime64 and some other data t = np.arange('2010-09-01','2010-09-02', dtype='datetime64[6h]') d = np.linspace(0,1,len(t)) I want to…
0
votes
1 answer

How to get the day difference between date-column and maximum date of same column or different column in Python?

I am setting up a new column as the day difference in Python (on Jupyter notebook). I carried out the day difference between the column date and current day. Also, I carried out that the day difference between the date column and newly created day…
0
votes
1 answer

How to get pandas to return datetime64 rather than Timestamp?

How can I tell pandas to return datetime64 rather than Timestamp? For example, in the following code df['dates'][0] returns a pandas Timestamp object rather than the numpy datetime64 object that I put in. Yes, I can convert it after getting it, but…
Steve Schulist
  • 931
  • 1
  • 11
  • 18
0
votes
0 answers

python datetime to np.datetime64

Is there a reason why conversion from datetime.datetime array, without specifying units us, converts the datetime to full day? Or is this a bug? import numpy as np import datetime print(np.array([datetime.datetime(2018, 5, 15, 6,…
kakk11
  • 898
  • 8
  • 21
0
votes
1 answer

How can I construct an elapsed time column from a column of pandas.datetime64?

I have a dataframe containing a column with: 3 3/20/2017 8:00:36 PM 4 3/20/2017 8:01:09 PM 5 3/20/2017 8:01:43 PM Name: ActualTime, dtype: object I want to create a column with the elapsed time in seconds. 0 33 67 Tried things like: t0 =…
Fred Mitchell
  • 2,145
  • 2
  • 21
  • 29
0
votes
2 answers

Timezone impact on Pandas converting datetime.datetime to datetime64

I'm trying to understand how pandas treats datetime stamps when added to a DataFrame. On my machine a date is stored 4 hours earlier. How can I stop this from happening? ex: import pandas as pd import datetime test =…
Stein
  • 401
  • 4
  • 6
0
votes
1 answer

Joining Dataframes on DatetimeIndex by Seconds and Minutes for NaNs

I'm looking for a good way to align dataframes each having a timestamp that "includes" seconds without loosing data. Specifically, my problem looks as follows: Here d1 is my "main" dataframe. ind1 = pd.date_range("20120101",…
Tim
  • 125
  • 3
  • 12
0
votes
1 answer

python xarray concat groupby in datetime64 dimensions

I have a xarray dataset that is: ds Dimensions: (lat: 360, lon: 720, time: 3652) Coordinates: * lon (lon) float32 -179.75 -179.25 -178.75 -178.25 -177.75 -177.25 ... * lat (lat) float32 89.75 89.25 88.75 88.25…
dreab
  • 705
  • 3
  • 12
  • 22