0

I'm trying to add values from a column in a Dataframe on Python with pandas, depending on the values of another column. If one row in a column is "non", I'd like to apply a specific task (put 0 in a another column) If one row in the same column is "oui", I'd like to add the value of the same row of another column.

I have a Dataframe which looks like that :

décennie FR total oui
1760-1769 oui 7
1760-1769 non 1
1770-1779 non 3
1780-1789 non 4
1790-1791 oui 4

And I would like to fill the column "oui" with the following condition :

  • If the value in the column "FR" --> non : put the value "0" in the column "oui"
  • If the value in the column "FR" --> oui : put the value of the column "oui"

Example

décennie FR total oui
1760-1769 oui 7 7
1760-1769 non 1 0
1770-1779 non 3 0
1780-1789 non 4 0
1790-1791 oui 4 4

Any idea ?

Thanks a lot for your ideas !

0 Answers0