Reputation: 433
I have two <class 'pandas.core.series.Series'>
which I will refer to as a
and b
. len(a)
returns 2400
, as does b
. I filtered a
by some predicate, e.g. a[lambda x: x == 0]
and this will yield a new series where the (timestamp) indices of a
are preserved.
time
2014-06-29 17:00:00 0.0
2014-06-29 18:00:00 0.0
2014-06-29 19:00:00 0.0
2014-06-29 20:00:00 0.0
2014-06-29 21:00:00 0.0
...
2014-10-15 22:00:00 0.0
2014-10-15 23:00:00 0.0
2014-10-16 00:00:00 0.0
2014-10-16 01:00:00 0.0
2014-10-16 02:00:00 0.0
Name: response, Length: 1323, dtype: float64
What I am seeking to do, is to look-up the values associated with these indices (timestamps) on b
.
Upvotes: 1
Views: 55
Reputation: 863166
IIUC use Index.isin
for filter by DatetimeIndex
es:
new = a[lambda x: x == 0]
#same working
new = a[a == 0]
b[b.index.isin(new.index)]
Upvotes: 1