I need a coder

  • Job DurationLess than a week
  • Project LevelBasic Level
  • Project deadlineExpired

Project detail

I have a list of numpy datetime64 objects, like so:

time_list_array = [numpy.datetime64(‘2021-01-01T07:23:00.000000000’),
numpy.datetime64(‘2021-01-01T07:25:00.000000000’),
numpy.datetime64(‘2021-01-01T07:26:00.000000000’),
numpy.datetime64(‘2021-01-01T07:27:00.000000000’),
numpy.datetime64(‘2021-01-14T16:27:00.000000000’)]
I want to loop through this list and modify it in a specific way.

Essentially, any time the difference between two datetime64 objects next to each other in the list is more than one minute, duplicate that datetime64 object and place it after the original one in the list.

Any time the difference between two datetime64 objects next to each other in the list is equal to a minute, move on to the next datetime64 object in the list until you come across a difference that is more than a minute. Then, take the first datetime64 object and the last datetime64 object in that range and place them next to each other.

So, my final time_list_array would look like this:

time_list_array = [numpy.datetime64(‘2021-01-01T07:23:00.000000000’),
numpy.datetime64(‘2021-01-01T07:23:00.000000000’),
numpy.datetime64(‘2021-01-01T07:25:00.000000000’),
numpy.datetime64(‘2021-01-01T07:27:00.000000000’),
numpy.datetime64(‘2021-01-14T16:27:00.000000000’),
numpy.datetime64(‘2021-01-14T16:27:00.000000000’)]
Notice how the 1/1/21 7:23:00 datetime64 object was duplicated and added directly after the original. Then, the range from 1/1/21 7:25:00 through 1/1/21 7:27:00 in the original array was shortened to just a start time and end time. Finally, 1/14/21 at 16:27:00 was once again duplicated and added directly after the original.

This needs to be formatted in this way to be exported to a txt file and consequently used in an online software program that only accepted txt files in a very specific format.

I have tried to find the time delta of time_list_array like so:

time_list_array_delta = np.diff(time_list_array)
And then find the difference in minutes:

minutes = time_list_array_delta.total_seconds()/60
But keep getting an error:

AttributeError: ‘numpy.ndarray’ object has no attribute ‘total_seconds’
I may be totally off base with my methods, however. Any help would be much appreciated!

Skills Required

Industry Categories

Freelancer type required for this project