Be the following python pandas DataFrame:
| ID | country | money | other | money_add |
|---|---|---|---|---|
| 832932 | France | 12131 | 19 | 82932 |
| 217#8# | ||||
| 1329T2 | ||||
| 832932 | France | 30 | ||
| 31728# |
I would like to make the following modifications for each row:
- If the
IDcolumn has any '#' value, the row is left unchanged. - If the
IDcolumn has no '#' value, and country is NaN, "Other" is added to the country column, and a 0 is added toothercolumn.
Finally, only if the money column is NaN and the other column has value, we assign the values money and money_add from the following table:
| other_ID | money | money_add |
|---|---|---|
| 19 | 4532 | 723823 |
| 50 | 1213 | 238232 |
| 18 | 1813 | 273283 |
| 30 | 1313 | 83293 |
| 0 | 8932 | 3920 |
Example of the resulting table:
| ID | country | money | other | money_add |
|---|---|---|---|---|
| 832932 | France | 12131 | 19 | 82932 |
| 217#8# | ||||
| 1329T2 | Other | 8932 | 0 | 3920 |
| 832932 | France | 1313 | 30 | 83293 |
| 31728# |