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
0 answers

Creating a time axis in pyqtgraph

enter image description herehere is my code y_value = self.data[header] self.plot_widget.plot(x=x_time, y=y_value, pen=self.color_dict[header], name=header) axis =…
0
votes
2 answers

How to fill an array with a fixed value of datetime64 data type in NumPy?

I want to fill a numpy array with a fixed datetime64 value. The output should look something like this: array(['2012-09-01', '2012-09-01', '2012-09-01', '2012-09-01', '2012-09-01'], dtype='datetime64[D]') Where the shape of the array and the…
0
votes
1 answer

Pandas to_gbq error due to type inconsistencies between MacOS and Windows

My Python/Pandas code is working fine on my MacOS, but now that I've moved it to Windows, it's not working due to type differences and I'm getting an error when trying to write to gbq (Google Big Query): The code is as follows: def formatNumber(x): …
dtam
  • 241
  • 1
  • 5
  • 15
0
votes
1 answer

How to display date in one line?

I have a minor problem with viewing one variable in a table. I changed data type of "date" from object to datetime64, but now it is displayed on 2 lines. This is the code I used. df['date']=pd.to_datetime(df["date"]) Is there a way to make it…
viktet
  • 1
  • 1
0
votes
2 answers

Converting a dataframe's datetime64[ns] index to a comparable datetime dtype

Trying to create a mask for my dataframe but can not compare the upper bound / lower bound datetimes to the index of the dataframe due to it being datetime64[ns]. I have seen the solution be to convert via pd.Timestamp - however I still get a value…
0
votes
1 answer

Substract 10 years from time variable in netCDF-file

I need to substract 10 years from the time variable (dimension) in a netCDF-file. The original input file starts at 1969-06-20 00:00 and ends at 1971-07-01 00:00, with 3H time steps. The time unit in the original file is unix seconds since…
Anna Sofia
  • 21
  • 1
0
votes
1 answer

python numpy.datetime64 array: filter by month

Assume I have this data set (or a more extensive one): import numpy as np array = np.array([ np.datetime64('2022-01-03'), np.datetime64('2022-05-03'), np.datetime64('2022-12-03') ]) I want to separate the dates by the month into…
0
votes
0 answers

Trying to solve a date discrepancy issue with timezone-aware data filtered from a csv between two dates

My problem is in finding the best-practice to resolve the issue of including all requested timezone-aware dates in a selected range. Depending on how I approach it, either the enddate or the startdate fail to return their date from the csv. I cannot…
mdkb
  • 372
  • 1
  • 14
0
votes
1 answer

add negative seconds using numpy date time

I'm trying to add an array of time offsets (in seconds, which can be both positive and negative) to a constant timestamp using numpy. numpy version is 1.19.1, python = 3.7.4 If "offsets" is all positive numbers, things work just fine: time0 =…
user3014653
  • 735
  • 2
  • 8
  • 13
0
votes
1 answer

Timestamp datetime64 to datetime in dataframe

I am confused with datetime64 and trying convert it to a normal time format. I have a column with timestamp format: 2022.01.02D23:10:12.197164900. Output expected is: 2022-01-02 23:10:12 I'm trying with: df['executionTime'] =…
0
votes
2 answers

Pandas mistake when reading date from excel file

Pandas error when reading date from excel file. I am creating a dataframe using the following command. df = pd.read_excel("report_file.xls", parse_dates=['operation_date']) df.dtypes operation_date datetime64[ns] Everything looks good. But when…
user15228599
  • 11
  • 1
  • 3
0
votes
1 answer

convert numpy array of float64 values to datetime64 with python and pandas

If I have a NumPy array of float64 values. I know these values represent dates in format of datetime64[ns]. I try to convert them with pandas. But I get an ValueError: Inferred frequency 86400N from passed values does not conform to passed frequency…
till Kadabra
  • 478
  • 9
  • 21
0
votes
1 answer

How to plot unix timestam

I have a time serie determined by sec.nsec (unix time?) where a signal is either 0 or 1 and I want to plot it to have a square signal. Currently I have the following code: from matplotlib.pyplot import * time = ['1633093403.754783918',…
aripod
  • 55
  • 1
  • 14
0
votes
1 answer

Writing to an XLSX without over-writing existing sheets

(1) I am trying to write to an existing XLSX file without erasing two tabs that already exist in the file. When I run the code chunk below, into my existing file, it overwrites sheets not named in the code. Can anyone suggest how I can write to my…
PG_CB
  • 1
0
votes
1 answer

Stacked Barplot with datetime64[ns] values. Using the first column as starting point

I have a dataset of runners going through checkpoints it looks like this: data = {'Runner': ['Tom', 'Joseph', 'Krish'], 'Start': [30/04/2021 05:27:19, 30/04/2021 05:33:50, 30/04/2021 05:43:32], 'First Checkpoint': [30/04/2021 05:40:45, 30/04/2021…
Jack
  • 722
  • 3
  • 8
  • 24