I have a dataframe with two columns 'ENTRYP' and 'Status'. If the value of ENTRYP is less than or equal to 0.02, it should change the 'status' to 'ENT_EXT'. Every time it crosses that range it should add count to the Status. For example: movement1, ent_ext1, movement2, ent_Ext2. I have written the below code but it is throwing the below error
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
h_count = 0
current = "ENT_EXT"
current == "MOVING"
status_halt = []
for idx in df2.index:
if (df2["ENTRYP"][idx] <= 0.02):
if current == "MOVING":
h_count += 1
status_halt.append(f"ENT_EXT{h_count}")
current = "ENT_EXT"
elif (df2["ENTRYP"][idx] > 0.02):
if current == "ENT_EXT":
m_count += 1
status_halt.append(f"MOVING_{m_count}")
current = "MOVING"
df2["Status"] = status_halt
I have added the snippet of the dataframe and required output.
Please let me know how to proceed https://i.stack.imgur.com/K0Qsj.png
Aucun commentaire:
Enregistrer un commentaire