I have data of the form
>>> df['image-capture_time'].iloc[-20:]
43 2022-07-19 20:08:26.603000+00:00
36 2022-07-19 20:08:28.313000+00:00
35 2022-07-19 20:08:29.571000+00:00
40 2022-07-19 20:08:30.796000+00:00
38 2022-07-19 20:08:32.062000+00:00
39 2022-07-19 20:08:33.346000+00:00
42 2022-07-19 20:08:34.579000+00:00
41 2022-07-19 20:08:35.813000+00:00
34 2022-07-19 20:08:37.062000+00:00
37 2022-07-19 20:08:38.314000+00:00
130 2022-07-22 15:12:05.925000+00:00
127 2022-07-22 15:12:07.531000+00:00
122 2022-07-22 15:12:08.765000+00:00
123 2022-07-22 15:12:10.031000+00:00
124 2022-07-22 15:12:11.298000+00:00
129 2022-07-22 15:12:12.548000+00:00
128 2022-07-22 15:12:13.781000+00:00
125 2022-07-22 15:12:15.032000+00:00
121 2022-07-22 15:12:16.298000+00:00
126 2022-07-22 15:12:17.532000+00:00
Name: image-capture_time, dtype: datetime64[ns, UTC]
where the values have been correctly sorted by increasing pandas.Timestamp
. But using
iloc[df['image-capture_time'].idxmax()]
does not return the record with the maximum time:
>>> df['image-capture_time'].iloc[df['image-capture_time'].idxmax()]
Timestamp('2022-07-22 15:12:11.298000+0000', tz='UTC')
>>> df['image-capture_time'].iloc[-1]
Timestamp('2022-07-22 15:12:17.532000+0000', tz='UTC')
>>> df['image-capture_time'].idxmax()
126
>>> df['image-capture_time'].iloc[131]
Timestamp('2022-07-22 15:12:17.532000+0000', tz='UTC')
What's going on here? Clearly there's something I don't understand about [iloc][1]
, idxmax
, or both (or maybe even [pandas.Timestamp][3]
).