For a dataframe, we know that
df.loc['a', 'col1'] = 1
If index 'a' does not exist, it will automatically create a row with index 'a' and set column col1 = 1. But it seems not work for
df.loc['a', 'col1'] += 1
How to solve it without checking if the index exists? i.e. if index 'a' does not exist, it will automatically create row with index 'a' and set column col1 = 0, then add 1 to 'col1'.
I tried for dictionary:
dict = {}
dict['a'] += 1
It seems also not allowed, which is different with the map in C++