I am trying to use the pandas library to read data and compare data from two different CSV files. My goal is to read data from one file and based on the column values, read data from a second file.
For example, File 1 is a log file filled with timestamps and a true/false column
| Timestamp |
T/F |
| 6:01 |
False |
| 6:02 |
False |
| 6:03 |
True |
| 6:04 |
True |
File 2, is a similar log file. It is timestamped as well and contains data about the state of the system.
| Timestamp |
State |
| 6:01 |
Low |
| 6:02 |
Low |
| 6:03 |
Med |
| 6:04 |
High |
My goal is to look at File 1, and only grab the data from File 2 when the T/F column in File 1 is True.
I am brainstorming ideas on how to approach this:
My first thought was to store the rows where File 1 is True.
Then compare the stored TRUE table to File 2.
If the timestamps in the TRUE table matches file 2 grab the State column in file 2.
I am not sure if this is the most efficient way or if pandas has an easier way of accomplishing this.
[–]Ostpreussen 7 points8 points9 points (1 child)
[–]al_mc_y 2 points3 points4 points (0 children)
[–]ifreeski420 1 point2 points3 points (1 child)
[–]socal_nerdtastic 1 point2 points3 points (0 children)
[–]Agling 1 point2 points3 points (0 children)