I have a dataframe which contains duplicate records with columns x,y,z,A
X    Y   Z   A
a   US   88  2016
a   IND  88  2016
a   IND  88  2017
a   RSA  45  2017
a   RSA  45  2018
b   US   65  2017
b   RSA  58  2018
c   RSA  58  2016
I want to create columns from the values of column A by having count of distinct countries for each vaue of X column.like below.
X     Z   2016  2017 2018 
a     88    2     1    0
a     45    0     1    1 
b     65    0     1    0
c     58    1     0    0
i couldn't figure out how to do this in python , pleas help me on this
