-
|
I have a DataArray which is called Now I want to find int index of a special time So what's my problem? How to solve this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
can solve my problem, but if you have better answer, please tell me. |
Beta Was this translation helpful? Give feedback.
-
|
you'd need to use the correct syntax for time_index = slice_array.loc[{"TM": special_time}]or time_index = slice_array.sel(TM=special_time)
# or
time_index = slice_array.sel({"TM": special_time})However, that will not give you the integer index, it will allow you to select data for a specific time. If you use that to index other arrays I'd suggest to put all of them into a single If you truly do need the integer index, you can try querying the underlying index object: slice_array.indexes["TM"].get_loc(special_time) |
Beta Was this translation helpful? Give feedback.
you'd need to use the correct syntax for
indexing:or
However, that will not give you the integer index, it will allow you to select data for a specific time. If you use that to index other arrays I'd suggest to put all of them into a single
Datasetand call thesel/locon that.If you truly do need the integer index, you can try querying the underlying index object: