Closed zashaavery closed 1 year ago
Hi @zashaavery ! Is this a chromatic
thing of trying to work with your simulated dataset, or something else? Happy to help here either way, but just want to get a little more context.
I think it's possible that instead of np.where
, you might want to use where = np.nonzero(epochtotal[0] == reconfloat[0])[0]
, which will return the indices where that boolean expression is nonzero (= not False). It actually returns two things, with only the first being the indices, so that's why you'd need the [0]
at the end after the function call.
Actually, I was able to just add the [0] at the end of my where statement and it worked! And this code is for my research methods class but I was stuck and decided to ask here!
Perfect, excellent!
For this code, I am trying to create an array that contains the indices at which specific times equal the overall time array. In the final line, I see that the index I need is 315334 but it is stuck in a format which I cannot use. I want to create an array of only those index values but it instead becomes: [(array([315334], dtype=int64),), (array([95050], dtype=int64),), (array([325311], dtype=int64),)] while I only need [315334, 95050, 325311]. Is there a way to do this? (some parts of my code are show below were epochtotal is a large array I created that contains the time arrays for a few files (dates). The 0 index just grabs the epoch/time data for the first date. reconfloat is a float value that contains the time at which an event occurs and I need to look at, but I need to find its index in the epochtotal array. Regarding the where statement, I am just finding where the reconfloat value is found in the epochtotal array for the first date.
print(epochtotal[0]) ##which prints [1.5539904e+09 1.5539904e+09 1.5539904e+09 ... 1.5540768e+09 1.5540768e+09 1.5540768e+09] print(reconfloat[0]) ##which prints 1554059286.074903 where = np.where(epochtotal[0] == reconfloat[0]) ##which prints [array([315334], dtype=int64)]