I have the following dataframe
| CustomerNr | Target | Source | Percentage |
|---|---|---|---|
| 1001 | A | C | 0.2 |
| 1004 | D | np.nan | 0.3 |
| 1005 | C | D | 0.4 |
| 1010 | A | D | 0.5 |
import numpy as np
df = pd.DataFrame([[1001, 'A','C',0.2], [1004, 'D',np.nan,0.3],[1005, 'C','D',0.4],
[1010, 'A','D',0.5]], columns=['CustomerNr','Target','Source','Percentage'])
to this one (any ideas how to formulate the title for this problem by the way)
import numpy as np
df = pd.DataFrame([['1001 Target' , 'A',0.2],
['1001 Source' , 'C',0.2],
['1004 Target', 'D',0.3],
['1004 Source', np.nan,0.3],
['1005 Target', 'C',0.4],
['1005 Source', 'D',0.4],
['10010 Target', 'A',0.5],
['10010 Source', 'D',0.5],
], columns=['CustomerNr Scope','Value','Percentage'])
| CustomerNr Scope | Value | Percentage |
|---|---|---|
| 1001 Target | A | 0.2 |
| 1001 Source | C | 0.2 |
| 1004 Target | D | 0.3 |
| 1004 Source | NaN | 0.3 |
| 1005 Target | C | 0.4 |
| 1005 Source | D | 0.4 |
| 10010 Target | A | 0.5 |
| 10010 Source | D | 0.5 |