I have used the following code to initialize a dictionary from the list of keys
z=df1[2].value_counts().keys().tolist()
mydict=dict.fromkeys(z,None)
further, I have used
value=df2[2].value_counts().keys().tolist()
counts=df2[2].value_counts().tolist()
    for j,items in value:
        if mydict.has_key(items):
            mydict.setdefault(items,[]).append(counts[j])
it is generating the following error
mydict.setdefault(items,[]).append(counts[j]) AttributeError: 'NoneType' object has no attribute 'append'
 
     
     
     
    