Issue
How can I write a code that shows me the indexes of Newdate
within Setups
. I want to get the index value for each of the date values, so for the first output;'2017-12-22T03:31:00.000000000'
date value in Newdate
comes 6th from the beginning from Setups
the output will be 5
.How would I be able to get the Expected Output
.
Code:
import numpy as np
Setups= np.array(['2017-09-15T07:11:00.000000000','2017-09-15T11:25:00.000000000',
'2017-09-15T12:11:00.000000000', '2017-12-22T03:14:00.000000000',
'2017-12-22T03:26:00.000000000', '2017-12-22T03:31:00.000000000',
'2017-12-22T03:56:00.000000000'],dtype="datetime64[ns]")
Newdate = np.array(['2017-09-15T07:11:00.000000000', '2017-12-22T03:31:00.000000000','2017-09-15T11:25:00.000000000', '2017-12-22T03:56:00.000000000'],dtype="datetime64[ns]")
Expected Output:
[0, 5, 1, 6]
Solution
You could convert setups to a list and use index()
:
setups_list = list(Setups)
indices = [setups_list.index(n) for n in Newdate]
print(indices)
# [0, 5, 1, 6]
Answered By - Zla Patka
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.