I've used the melt function and it is exactly what I am after and working perfectly. However, how can I take this view and export it into Excel?
Even when I call the df after using the melt function, it reverts back into the 'un'melted df (long to wide)
all_recons.melt(id_vars=["Client Name", "Client Code"],
var_name="Date",
value_name="Cost to Client")
Client Code Date Cost
237762 01/01/2024 98.91438
237762 01/01/2024 108.1454
101145 01/01/2024 113884.02025
101145 01/02/2024 1525.90438
101145 01/02/2024 4427.17275
Then why I try and call my df again it reverts back to the long to wide format
all_recons
Client Code 01/01/2024 01/02/2024
237762 98.91438 NaN
237762 108.1454 NaN
101145 113884.02025 NaN
101145 Nan 1525.90438
101145 NaN 4427.17275
I'd like it so that the df stays in the melted state and then I can export to Excel