Skip to content
Advertisement

Clean Data using Pandas

I have the data in this format, and I want to turn it around in an horizontal shape, and in the same time accumulate the count of one product, when the date and hour data are the same.

I put below the new desired data frame. Is this feasible using pandas? Or any other python library?

JavaScript

Advertisement

Answer

You could groupby+sum, then unstack, finally rework the column names:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement