0
I am trying to add columns between two tables "daily" and "monthly" as a way to update the columns "sum" and "Count". However, for some lines the sum returns empty. The file "diario" has 4800 lines and the monthly 5642 lines. For files with less than 100 lines there was no such problem.
The code and the sample images are:
# Lê ambos os arquivos e armazena em tabelas do Pandas
diario = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/diario.csv')
mensal = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/mensal.csv')
mensal_ini = mensal.copy()
mensal.loc[(mensal['imsi'].isin(diario['imsi'])) & (mensal['operadora'].isin(diario['operadora'])), "sum"] += diario['sum']
mensal.loc[(mensal['imsi'].isin(diario['imsi'])) & (mensal['operadora'].isin(diario['operadora'])), "count"] += diario['count']
mensal = pd.concat([mensal, diario]).drop_duplicates(subset=['imsi','operadora'])
f = open("/content/drive/MyDrive/Colab Notebooks/mensal_result.csv", 'w')
f.writelines(mensal.to_csv(index=False))
f.close()
Result with failures in some sum fields:
The two tables with all fields completed, but resulting in the blank field