My problem is the same as this one, with an additional constraint I can't figure how to solve :
Python PANDAS: Drop All Rows After First Occurrence of Column Value
In this post, the issue is to remove all lines once Open occurred for the 1st time :
Start :
Rank Status
1 Closed
5 Closed
6 Open
9 Closed
10 Open
Result :
Rank Status
1 Closed
5 Closed
6 Open
Here's the best answer to the problem :
df = df.sort('Rank').reset_index()
df.loc[: df[(df['Status'] == 'Open')].index[0], :]
I have the same problem, but I have multiple Shops in the same dataframe, and want it computed for all of them :
Start :
Shop Rank Status
A 1 Closed
A 5 Closed
A 6 Open
A 9 Closed
A 10 Open
A 1 Closed
B 3 Closed
B 8 Closed
B 12 Open
B 15 Closed
...
The result I want :
Shop Rank Status
A 1 Closed
A 5 Closed
A 6 Open
B 3 Closed
B 8 Closed
B 12 Open
...
How shall I modify the past answer to adapt it to all my Shops at the same time?
Thanks in advance