Reputation: 12203
I have a dataframe with 5 rows on which I am doing some validations. If the row does not pass validation, I am adding it to a second dataframe named ValidationFailedDataFrame.
It is OK for the first validation but for the second validation, I want to check if the particular row is already added to the ValidationFailedDataFrame or not and if it is, I want to grab that row and append the error message.
This is how my ValidationFailedDataFrame looks like:
As you can see in the picture, the row that failed the validation was 4th row in the original DataFrame.
How do I query ValidationFailedDataFrame saying give me 4th row of Original DataFrame if you have?
Upvotes: 1
Views: 4083
Reputation: 12203
Got it.
ValidationFailedDataFrame.query('index == 4')
OR
ValidationFailedDataFrame.loc[[4]]
Upvotes: 1