I have a nested dictionary created as follows
>>> groups = dict.fromkeys(member_df.iloc[0:10].GROUP_ID.unique(), dict())
>>> print(groups)
{'1' : {}, '2': {}, '3': {}, '4':{}, '5':{}}
This gives unexpected behavior, because if I do something like
>>> groups['1']['a'] = 1
This gives
>>> groups
{'1': {'a': 1}, '2': {'a': 1}, '3: {'a': 1}, '4': {'a': 1}, '5: {'a': 1}}
However, if I initialize groups manually then I get the expected behavior
>>> groups = {'1' : {}, '2': {}, '3': {}, '4':{}, '5':{}}
>>> groups['1']['a'] = 1
>>> groups
{'1' : {'a': 1}, '2': {}, '3': {}, '4':{}, '5':{}}
I'm using Python 3.5.4
Anyone know what might be causing this seemingly discrepant behavior?