Reputation: 177
I am trying to find the points in a dataframe where the data hits a max value, holds it for a time, then drops down again (See image below).
I am attempting to find the index's where the value first hits the max and where it first leaves it. I've attempted it in the following way.
ent = data.loc[data['ESC_Command'] == 1600 and data['ESC_Command'].shift() < 1600]
lve = data.loc[data['ESC_Command'] == 1600 and data['ESC_Command'].shift(-1) < 1600]
But when I run this I get the following error.
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
If I run either the 'equals to 1600' or the '< 1600' with the shift I get the expected boolean list but adding a logical statement gets me that error. Don't suppose anyone can shed some light onto what I'm missing?
Thanks in advance!
Upvotes: 0
Views: 636
Reputation: 345
You will want to use the bitwise operator (&
) to combine your masks ((data['ESC_Command'] == 1600) & (data['ESC_Command'].shift() < 1600)
).
and
is the logical operator and is unable to compare series, hence the ValueError
.
Also, you can use data['ESC_Command'].max()
to dynamically find the maximum value in the column.
Upvotes: 1