I'm trying to remove Dataframe rows using multiple conditions from one Dataframe (df1
) based on values from a second Dataframe (df2). The data I'm interested in comparing within these dataframes is labelled 'Timestamp' (T
) and 'delta_t' (dt
).
The function I'm looking to apply is that when T_{df1} == T_{df2}
, then remove all lines where dt_{df2} - 0.1 < dt_{df1} < dt_{df2}
In other words, when the timestamp values from each dataframe are equal, I then want to compare the delta_t values. If the delta_t
values of df_1
fall within a +/- range of 0.1 of the delta_t
values of df2
, then remove these rows from the df1.
Any help is much appreciated!
Cheers!
I have tried using df1.loc['timestamp'].isin(df2['timestamp']
to acquire the rows with corresponding timestamp values. BUt I'm not sure how to compare the delta_t
values and remove lines which fall within a specific range.
EDIT: The data is originally saved in one dataframe with many columns. One of the columns is labelled 'channels'. To form the two dataframes (df1, df2) that I compare, I separate based on the channel value using the following:
noise = df1[df1['channel'] == 3]['timestamp_copy'] df2 = df1.loc[(df1['timestamp_copy'].isin(noise))]
Therefore, the number of rows in df1 >> df2.