Jan-09-2020, 04:18 PM
One way to keep last row from filtered rows is to use .tail(n=1):
>>> import pandas as pd >>> df = pd.DataFrame([1, 2, 1, 2, 3, 3]) >>> df 0 0 1 1 2 2 1 3 2 4 3 5 3 >>> df.loc[df[0] == 2].tail(n=1) 0 3 2
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.