Skip to main content
0 votes
1 answer
71 views

Importing CSV after initially exporting datetime output (without using pandas)

I use the following to write CSV lines in a loop while running sensor instrumentation, and I want to read them back in for post-processing without pandas. I would like to use the imported data to ...
onix's user avatar
  • 3
1 vote
1 answer
59 views

numpy.ndarray of seconds of a day to datetime format

I have a Python numpy.ndarray of seconds of the day with a bunch of decimal seconds: import numpy as np sec = [40389.66574375, 40390.12063928, 40391.32714992, 40392.64457077, 40393.48519607, 40394....
Swawa's user avatar
  • 273
7 votes
2 answers
177 views

Why does `strftime("%Y")` not yield a 4-digit year for dates < 1000 AD in Python's datetime module on Linux?

I am puzzled by an inconsistency when calling .strftime() for dates which are pre-1000 AD, using Python's datetime module. Take the following example: import datetime old_date = datetime.date(year=33, ...
Melipone's user avatar
  • 730
2 votes
1 answer
64 views

Why datetime.datetime.strptime %Z code doesn’t produce an aware object?

A little example: $ python Python 3.13.2 (main, Feb 5 2025, 08:05:21) [GCC 14.2.1 20250128] on linux Type "help", "copyright", "credits" or "license" for more ...
ctmbl's user avatar
  • 23
3 votes
1 answer
77 views

Python ValueError: ':' is a bad directive in format '%Y-%m-%d%X%:z'

I'm attempting to parse HTML time strings in Python: from datetime import datetime input = "2025-03-24T07:01:53+00:00" output = datetime.strptime(input, "%Y-%m-%d%X%:z") print(...
The-Coder-Who-Knew-Too-Little's user avatar
0 votes
1 answer
59 views

datetime.strptime() is blocking asyncio.Queue.get() [duplicate]

In the following code datetime.strptime() is blocking asyncio.Queue.get() operation import time import asyncio from datetime import datetime from functools import partial def write(queue): data =...
Dinesh's user avatar
  • 1,886
0 votes
0 answers
80 views

pyqtgraph: Show x axis labels in the form DD HH:MM:SS of data representing timedeltas with DateAxisItem

I am trying to use pyqtgraphs DateAxisItem for relative times on the x axis, i.e., durations (which can be between a few hours and several days). I know I could simply use an ordinary AxisItem and ...
emma's user avatar
  • 357
0 votes
1 answer
64 views

I have a time in string format, which is of New York. I want the time to be converted to UTC in Python

Input (New York Time in string format) = '2024-11-01 13:00:00' Output (UTC Time in string format) = '2024-11-01 17:00:00'
Alpha Warrior's user avatar
2 votes
2 answers
141 views

Determine whether a given date string includes all three components: day, month, and year

I am trying to determine whether a given date string includes all three components: day, month, and year. Example Inputs and Expected Outputs: "2025-01-01" → True (All components are ...
Chinmai Veera's user avatar
0 votes
1 answer
52 views

Python Async Function not updating timestamp

I have a machine running some scripts that I need to keep an eye on. I have set up a script in python to send me emails using every hour. I would like to add timestamp to it so that I can see at a ...
excelman's user avatar
  • 439
0 votes
1 answer
111 views

How to save dataframe after shifting its columns using date as index

When I use .shift() from Pandas on a column in a DataFrame with a date index, I can use it, for example, with .corr(), but I cannot update my old DataFrame or create a new one. Dataset My df looks ...
Mihuu's user avatar
  • 1
1 vote
2 answers
102 views

In python (pytz), how can I add a "day" to a datetime in a DST-aware fashion? (Sometimes the result should be 23 or 25 hours in in the future)

I'm doing some datetime math in python with the pytz library (although I'm open to using other libraries if necessary). I have an iterator that needs to increase by one day for each iteration of the ...
Pwnosaurus's user avatar
  • 2,186
-1 votes
1 answer
321 views

Pandas Datetime conversion CET/CEST to UTC

I have a df datetime column that I want to convert from Europe/Copenhgaen t.z to UTC but I just keep getting duplicate entries in the UTC column. The reason this happens is because of how I make my ...
Tom's user avatar
  • 115
1 vote
1 answer
59 views

Why cannot I not maintain the timezone information with matplotlib mdates

I need to plot some patches which requires me to use the matplotlib mdate module (ideally) to have control over the tick markers. I have used mdates before and I can't for the life of me figure out ...
Yolkions's user avatar
  • 111
0 votes
1 answer
57 views

How do I get the time difference between 2 sets of datetime objects in hours? Python

I'm connecting to an API that returns a list of articles, each article has created_at and modified_at properties. I want to return the difference (in hours) between the created_at and modified_at ...
Katie's user avatar
  • 9

15 30 50 per page
1
2 3 4 5
129