outputfile = 'file' + str(i) + str(i + 1)
if i == len(flist) - 3 and len(flist) % 2 == 1:
    merged_data = pd.merge(merged_data, store[flist[i + 2]], on='key', how=
        'outer', sort=False)
outputfile += str(i + 2)
merged_data = merged_data.fillna(0)
store.put('/tmp' + str(counter) + '/' + outputfile, merged_data)
store.flush()
to_remove = [file for file in list(store.keys()) if 'tmp' + str(counter) + '/' not in
    file]
for file in to_remove:
    store.remove(file)
flist = list(store.keys())
store.close()
return merged_data
Outer join in Python for thousands of large tables