Jun-19-2022, 07:18 PM
(This post was last modified: Jun-19-2022, 07:18 PM by deanhystad.)
If it is guaranteed that the two files will contain the same timestamps you can do this:
import pandas as pd import io f1 = io.StringIO(""" 20220617 14:30:00, 1.1 20220617 14:40:00, 1.3 20220617 14:50:00, 1.7 20220617 15:00:00, 1.4 """) f2 = io.StringIO(""" 20220617 14:30:00, 2.1 20220617 14:40:00, 2.3 20220617 14:50:00, 2.7 20220617 15:00:00, 2.4 """) df1 = pd.read_csv(f1, names=("Date", "Value")) df2 = pd.read_csv(f2, names=("Date", "Value")) print(df1) print(df2) print(df1 + df2)
Output: Date Value
0 20220617 14:30:00 1.1
1 20220617 14:40:00 1.3
2 20220617 14:50:00 1.7
3 20220617 15:00:00 1.4
Date Value
0 20220617 14:30:00 2.1
1 20220617 14:40:00 2.3
2 20220617 14:50:00 2.7
3 20220617 15:00:00 2.4
Date Value
0 20220617 14:30:0020220617 14:30:00 3.2
1 20220617 14:40:0020220617 14:40:00 3.6
2 20220617 14:50:0020220617 14:50:00 4.4
3 20220617 15:00:0020220617 15:00:00 3.8
Instead of printing you would (df1 + df2).write_csv(file_path)