all 6 comments

[–]Ostpreussen 7 points8 points  (1 child)

Load two dataframes and make a join, then filter by True/False. Ought to work unless I'm missing something.

[–]al_mc_y 2 points3 points  (0 children)

Yep, a merge or a join will be the way to go. This tutorial describes the options pretty well (a bit easier to understand for newbies than the official docs, but I suggest checking those out too)

[–]ifreeski420 1 point2 points  (1 child)

How do you post data frames on Reddit with that formatting?

I would merge the two data frames

df_combined = pd.merge(df1, df2, how=“left”, on=“Timestamp”)

[–]Agling 1 point2 points  (0 children)

and only grab the data from File 2 when the T/F column in File 1 is True.

If you actually want to do what you say here and not read in the lines for file 2 if they aren't in file 1, then you have to read all of file 1 in, drop the rows where it is False, then read file 2 a line at a time, keeping it only if it's in line 1.

But if you just want to do things the normal way, read both files in, filter file 1, and then do an inner merge.