Skip to main content
added 12 characters in body
Source Link
Deke Marquardt
  • 161
  • 1
  • 1
  • 10

I am looking for a code that would get rid of rows for instances where the SCU_KEYREVENUE_STATUS_FLAG is 0 before it becomes 1. HOWEVER, I would not like to get rid of the 0's after where 1 has occurred for that SCU_KEY (which is all based on sorted date). So with the image shown, the values I would like to get rid of these rows, which I categorized based on the index:

1166, 221 - (first two off SCU_KEY 3)

333, 1645, 1614 - (from SCU_KEY 14)

You will notice that I don't want to get rid of 334 from SCU_KEY 3 and that is because of the 1 occurring right before it from 45. This df is bigger than is shown so manually inputting the specific numbers mentioned does not suffice. enter image description here

I am looking for a code that would get rid of rows for instances where the SCU_KEY is 0 before it becomes 1. HOWEVER, I would not like to get rid of the 0's after where 1 has occurred for that SCU_KEY (which is all based on sorted date). So with the image shown, the values I would like to get rid of these rows, which I categorized based on the index:

1166, 221 - (first two off SCU_KEY 3)

333, 1645, 1614 - (from SCU_KEY 14)

You will notice that I don't want to get rid of 334 from SCU_KEY 3 and that is because of the 1 occurring right before it from 45. This df is bigger than is shown so manually inputting the specific numbers mentioned does not suffice. enter image description here

I am looking for a code that would get rid of rows for instances where the REVENUE_STATUS_FLAG is 0 before it becomes 1. HOWEVER, I would not like to get rid of the 0's after where 1 has occurred for that SCU_KEY (which is all based on sorted date). So with the image shown, the values I would like to get rid of these rows, which I categorized based on the index:

1166, 221 - (first two off SCU_KEY 3)

333, 1645, 1614 - (from SCU_KEY 14)

You will notice that I don't want to get rid of 334 from SCU_KEY 3 and that is because of the 1 occurring right before it from 45. This df is bigger than is shown so manually inputting the specific numbers mentioned does not suffice. enter image description here

Source Link
Deke Marquardt
  • 161
  • 1
  • 1
  • 10

deleting specific rows of a dataframe based on a certain condition

I am looking for a code that would get rid of rows for instances where the SCU_KEY is 0 before it becomes 1. HOWEVER, I would not like to get rid of the 0's after where 1 has occurred for that SCU_KEY (which is all based on sorted date). So with the image shown, the values I would like to get rid of these rows, which I categorized based on the index:

1166, 221 - (first two off SCU_KEY 3)

333, 1645, 1614 - (from SCU_KEY 14)

You will notice that I don't want to get rid of 334 from SCU_KEY 3 and that is because of the 1 occurring right before it from 45. This df is bigger than is shown so manually inputting the specific numbers mentioned does not suffice. enter image description here