I am iterating some code over a directory and I want to sum the values of same keys from dictionaries that I get.
The code is counting how many times a word appears in a column of a .csv file. It does that with every .csv file in the given folder.
I want an output of added values of same keys. Eg. first file had the word "dog" three times and the second had it 4 times. I want to add these two numbers.
The code to count words:
for file in os.scandir(directory):
if file.path.endswith(ext):
df = pd.read_csv(file)
klasifikacija = df.iloc[:, 4] # Gets all rows for the fourth column (index starts at 0)
napake = klasifikacija.value_counts()
dict_napake = dict(napake)