I have a dataframe that looks like that :
data = {'Place A':['New York', 'Oslo', 'Oslo'], 'Place B':['Paris','London','London'], 'Type':['A','B','A'], 'Number' : [34,42,24]}
df = pd.DataFrame(data)
print(df)
| Place A | Place B | Type | Number |
|---|---|---|---|
| New York | Paris | A | 34 |
| Oslo | London | B | 42 |
| Oslo | London | A | 24 |
i need to have the percentage number of each type according to the routes.
I don't know witch command to use to get a dataframe that looks like this
| xxx | Paris | Oslo | London | New York |
|---|---|---|---|---|
| Paris | NaN | NaN | NaN | type A : 100% |
| Oslo | NaN | NaN | type A : 36,3% type B : 63,6% | NaN |
| London | NaN | type A : 36,3% type B : 63,6% | NaN | NaN |
| New York | type A : 100% | NaN | NaN | NaN |