Skip to content

timestamp() error on Windows with dates before 1970 #5

@Biggels

Description

@Biggels

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()
  • or when setting 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions