I have data like below:
id  movie   details value
5   cane1   good    6
5   wind2   ok  30.3
5   wind1   ok  18
5   cane1   good    2
5   cane22  ok  4
5   cane34  good    7
5   wind2   ok  2
I want the output with below criteria:
If movie name starts with 'cane' - sum the value
If movie name starts with 'wind' - count the occurrence.
So - the final output will be:
id  movie   value
5   cane1   8
5   cane22  4
5   cane34  7
5   wind1   1
5   wind2   2
I tried to use:
movie_df.groupby(['id']).apply(aggr)
def aggr(x):
    if x['movie'].str.startswith('cane'):
        y = x.groupby(['value']).sum()
    else:
         y = x.groupby(['movie']).count()
    return y
But It's not working. Can anyone please help?