mercredi 24 juin 2020

How do I add a row to a DF based on a condition checking if a value exists in a column

I try to find a solution, but I can't :(

I have a DF where one of the columns is a "child" and another is "parent".

I need to check if the parent exists in a "child" column as a child itself, If not I want to create a new row where the value from the "parent" field will be entered as a "child" value and all the other values will be entered manually.

a_b_c - child; a_b - parent

a_b - child; a - parent

if a_b exists, do nothing and check next row, if not - create "a_b" child with "a" parent

Thank you soo much :)

Aucun commentaire:

Enregistrer un commentaire