1,932 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
78
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 ...
1
vote
1
answer
62
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....
7
votes
2
answers
200
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, ...
2
votes
1
answer
78
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 ...
3
votes
1
answer
84
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月24日T07:01:53+00:00"
output = datetime.strptime(input, "%Y-%m-%d%X%:z")
print(...
user avatar
user12532589
0
votes
1
answer
63
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 =...
0
votes
0
answers
97
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 ...
0
votes
1
answer
70
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'
2
votes
2
answers
159
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 ...
0
votes
1
answer
67
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 ...
0
votes
1
answer
116
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 ...
1
vote
2
answers
112
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 ...
-1
votes
1
answer
378
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 ...
1
vote
1
answer
71
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 ...
0
votes
1
answer
58
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 ...