I am working on Titanic dataset  

One ticket can be issued for several passengers, i. e. several passengers may have same ticket number  

The 'Fare' feature for all those passengers will be the same and equal to the whole ticket fare  

For example if there are 4 passengers travelling by one ticket, the ticket fare can be 40$, but each passenger fare should be $10.  

So one should divide ticket fare by ticket frequency to calculate fare per passenger.  

But there is one more thing: babies are charged $2 and children younger 12 are charged half adult fare.  

So I am trying to calculate price payed by each adult in the ticket taking into account children fares.  

Here is a sample data frame:

```
df = pd.DataFrame({'Age': [0.5,5,20,21,22,23,24], 'Fare': [17,17,17,40,40,40,40], 'TicketNum': [1,1,1,2,2,2,2]})

```

```
 **Age Fare TicketNum**  

0      0.5       17         1  

1      5.0       17         1  

2      20.0      17         1  

3      21.0      40         2  

4      22.0      40         2  

5      23.0      40         2  

6      24.0      40         2  

```

first I make this function:

```
def fare_calc(x):
    ticket_fare = x['Fare'].mean()

    group_size = x.shape[0]
    babies_count = x[x['Age']<1].count()
    child_count = x[x['Age']<12].count()
    adult_count = group_size - babies_count - child_count
    adult_fare = (ticket_fare - babies_count * 2) / (adult_count + child_count*0.5)
    return adult_fare

```

then I try:

```
df['TicketFreq'] = df.groupby('TicketNum')['TicketNum'].transform('count')
df['Fare2'] = df[df.TicketFreq>1].groupby(['TicketNum'])['Age','Fare'].agg(fare_calc)

```

and get an error:  

ValueError: Wrong number of items passed 2, placement implies 1

desired output is the following:

```
 **Age Fare TicketNum Fare2**  

0      0.5       17         1           10  

1      5.0       17         1           10  

2      20.0      17         1           10  

3      21.0      40         2           10  

4      22.0      40         2           10  

5      23.0      40         2           10  

6      24.0      40         2           10  

```