<SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
I am trying to groupby counts of dates per month and year in a specific output. I can do it per day but can't get the same output per month/year. 
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
d = ({'Date': ['1/1/18','1/1/18','2/1/18','3/1/18','1/2/18','1/3/18','2/1/19','3/1/19'],
      'Val': ['A','B','C','D','A','B','C','D']})
df = pd.DataFrame(data=d)
def g(df):
    df['Date'] = pd.to_datetime(df['Date'], format='%d/%m/%y')
    y = df['Date'].dt.year
    m = df['Date'].dt.month
    df['Count_d'] = df.groupby('Date')['Date'].transform('size')
    df['Count_m'] = df.groupby([y, m])['Date'].transform('size')
    df['Count_y'] = df.groupby(y)['Date'].transform('size')
    return df
df = g(df.copy())
<END_TASK>