I need to merge 2 data frames with Pandas. I'm using Jupyter Notebook.
I can merge but I cannot filter the data (like a WHERE statement on SQL).
The data frames have equal messages that were labeled with 0 or 1 by the labelers.
The data frames have 3 columns with equal values - Id
, timestamp
, message
and 2 columns high, low
with different values of labeling (1 or 0)
I did the merge on column 'Id'
I am trying to see for example:
Is there any time that Df1 has the column 'high' with value == 1 and the Df2 has the column 'low' with value == 1 for the same statement? or vice-versa?
df1.merge(df2, on = ['Id'], how = 'inner')
now I need to filter, but I can't find the right syntax...
(df1[(df1["high_df1"] == 1)]) & (df2[(df2["low_df2"] == 1)])
I could visualize the answer with separate statements:
df1.loc[(df1['high_df1'] == 1) & (df2['low_df2'] == 1)]
df2.loc[(df2['low_df2'] == 1) & (df1['high_df1'] == 1)]
But I would like to see the results in one table.
Can anyone help me?