I'm aiming to pass a groupby count of values but only considering rows where `Item` and `Item 2` are different. The following achieves this but drops rows if no values are different. If there are one or more values that are present but are identical between `Item` and `Item 2` then I'm hoping to return 0.

```
import pandas as pd

df = pd.DataFrame({
    'Time' : [1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,4,4,4],  
    'Item' : ['A','A','A','A','A','A','A','B','B','B','B','B','B','B','A','B','B','B'],                  
    'Item2' : ['B','A','A','A','B','B','B','A','A','B','A','B','B','B','A','B','A','A'], 
    'Value' : [5, 6, 6, 5, 5, 6, 5, 6, 3, 1, 4, 6, 7, 4, 5, 1, 2, 3],                         
    })

df1 = df[df['Item'] != df['Item2']].groupby(['Time']).size().reset_index(name='count') 

```

Intended Output:

```
   Time  count
0     1      4
1     2      3
2     3      0
3     4      2

```

Edit 2:

```
df = pd.DataFrame({
    'Time' : ['1','1','1','1','1','1','1','2','2','2','2','2','2','2','3','4','4','4'],  
    'Item' : ['A','A','A','A','A','A','A','B','B','B','B','B','B','B','A','B','B','B'],                  
    'Item2' : ['B','A','A','A','B','B','B','A','A','B','A','B','B','B','A','B','A','A'], 
    'Value' : [2, 6, 6, 5, 3, 3, 4, 6, 5, 1, 4, 6, 7, 4, 5, 1, 2, 3],                         
    })

df1 = (df.assign(new = df['Item'] != df['Item2'])
   .groupby('Time')['new']
   .mean()
   .reset_index(name='avg') 
   )

```

Intended Output:

```
  Time      avg
0    1      3.0
1    2      5.0
2    3      0.0
3    4      2.5

```