df.head().info()
RangeIndex: 5 entries, 0 to 4
Data columns (total 4 columns):
id 5 non-null object
date-hr 5 non-null object
channel 5 non-null object
hr 5 non-null int64
dtypes: int64(1), object(3)
Actual date-hr looks something like
'2017-02-14--15'
id is a string
I have a df like:
User-ID | Date-hr | Channel | Hr
U1 D1-10 C1 10
U1 D1-11 C2 11
U1 D1-10 C1 10
U1 D1-10 C3 10
U1 D1-10 C1 10
U1 D1-11 C3 11
U1 D1-11 C2 11
..
when I apply pivot operation with user-id as index and columns as
['date-hr', 'channel']
using count as the aggregation function.
I get 1 row for every user with the primary index as date-hr and all channels under that one date-hr value like:
D1-10 D1-11 .....
C1 C3 C2 C3 .....
U1 3 1 2 1 .....
Now what I require is max channel under every 'date-hr' with the count
D1-10 D1-11 .....
C1 C2 .....
U1 (C1,3) (C2,2) .....
I can't figure it out how to get this transformation from my data.