0

I try to convert second data since 1993/01/01 like this

time = [7.57382412e+08, 7.57382436e+08, 7.57382461e+08, ...,
   7.88918357e+08, 7.88918381e+08, 7.88918406e+08]

I can convert it one by one like this

datetime.datetime(1993,1,1) + datetime.timedelta(seconds=time[0])

If I enter the array into timedelta

datetime.datetime(1993,1,1) + datetime.timedelta(seconds=time)

It is showing a TypeError:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: unsupported type for timedelta seconds component: numpy.ndarray

How can I figure it out ?

2
  • You have to loop through the list Commented Jan 7, 2021 at 6:29
  • Note that Python will treat the starting point as local time if you don't set a time zone (e.g. as UTC, tzinfo=datetime.timezone.utc). Commented Jan 7, 2021 at 6:39

1 Answer 1

1

Try using list comprehension as below:

[datetime.datetime(1993,1,1) + datetime.timedelta(seconds=each) for each in time]

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.