lundi 11 juillet 2016

pandas dataframe- replace row values


I have a dataframe with four columns (see input dataframe below). I need to check if Meta column has pattern relation (example M_relation) then add number from relation column to the meta column value. How this can be done in pandas?

Input dataframe:

--------------------------------------

    Entry1 | Relation | Entry2 | Meta |

--------------------------------------

E11 | R_31 | E21 | M_xxx |

E12 | R_21 | E51 | M_relation |

E33 | R_21 | E51 | M_yyy |

E44 | R_41 | E46 | M_relation |

Output:

--------------------------------------
Entry1 | Relation | Entry2 | Meta |
--------------------------------------

E11 | R_31 | E21 | M_xxx |

E12 | R_21 | E51 | M_relation_21 |

E33 | R_21 | E51 | M_yyy |

E44 | R_41 | E46 | M_relation_41 |
--------------------------------------

Aucun commentaire:

Enregistrer un commentaire