-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
timestamp() error on Windows with dates before 1970 #5
Comments
i hope this helps,similar problem also,set your date back by 1 year and try again |
Hi @Biggels , apologies for the delay (and thank you @spidyhackx for helping out.) Thanks for reporting. I don't have access to a Windows machine, so it is difficult for me to debug this. I'm glad you were able to work around it in the main notebook. For the plotting: an easy fix would be to call Would the following change in
|
Thanks for the tip on setting ticklabels manually. Seems obvious in hindsight :) As for your suggested change, I don't believe you can add a float directly to a datetime object. From some testing, it looks like you have to convert the float time in seconds to a timedelta object first. The following snippet, for example, worked for me to convert all the float times in my dictionary of observations to datetime objects:
|
Ah, yes, makes sense. OK, I'll change this in the plotting function 👍 |
Hi there,
I'm working through your NBA example, and I'm noticing that anywhere where we're trying to use
.timestamp()
, e.g.t = datetime.strptime(row["date"], "%Y-%m-%d").timestamp()
timestamps=True
in the plotting (ts = [datetime.fromtimestamp(t) for t in ts]
)it throws an error when encountering dates before 1970, as below:
OSError: [Errno 22] Invalid argument
This doesn't happen in the online notebook, and from some googling it sounds like it's a Windows specific issue. I was able to work around it in the main section by simply manually calculating the timedelta and converting it to seconds (
t = (datetime.strptime(row["date"], "%Y-%m-%d") - datetime(1970, 1, 1)).total_seconds()
), but that doesn't help me with the plotting, unfortunately.Do you have any suggested workarounds or fixes? Let me know if any more info is needed.
Edit: To clarify, I'm running Python 3.8 in Spyder 4.1.1 on Windows
The text was updated successfully, but these errors were encountered: