Here is my dataframe,

```
 df = pd.DataFrame({'Id': [102,103,104,303,305],'ExpG_Home':[1.8,1.5,1.6,1.8,2.9],
                  'ExpG_Away':[2.2,1.3,1.2,2.8,0.8],
                  'HomeG_Time':[[93, 109, 187],[169], [31, 159],[176],[16, 48, 66, 128]], 
                  'AwayG_Time':[[90, 177],[],[],[123,136],[40]]})

```

First, I need to create an array `y`, for a given Id number, it takes values from same row (`ExpG_Home & ExpG_Away`).

```
y = [1 - (ExpG_Home + ExpG_Away), ExpG_Home, ExpG_Away]

```

Second, **I found this much harder**, for the Id used in creating `y`, the function below takes the corresponding lists from `HomeG_Time & AwayG_Time` and creates an array. Unfortunately, my function takes one row at a time. I need to do this for a large dataset. 

```
x1 = [1,0,0]    
x2 = [0,1,0]    
x3 = [0,0,1]    
total_timeslot = 200      # number of timeslot per game.
k = 1    # constant

#For Id=102 with ExpG_Home=2.2 and ExpG_Away=1.8
HomeG_Time = [93, 109, 187]  
AwayG_Time = [90, 177]
y = np.array([1-(2.2 + 1.8)/k, 2.2/k, 1.8/k])
  # output of y = [0.98 , 0.011, 0.009]

def squared_diff(x1, x2, x3, y):
    ssd = []
    for k in range(total_timeslot):  
        if k in HomeG_Time:
            ssd.append(sum((x2 - y) ** 2))
        elif k in AwayG_Time:
            ssd.append(sum((x3 - y) ** 2))
        else:
            ssd.append(sum((x1 - y) ** 2))
    return ssd

sum(squared_diff(x1, x2, x3, y))
Out[37]: 7.880400000000012

```

This output is for the first row only.