Each row in my DataFrame has two date columns. How can I filter out the rows in which 'Date A' is after 'Date B'?
Example:
symbol |    reports_at       |    as_of        |      signal   
...   
A     | 2012-02-15T21:00:00Z |  2012-02-01T12:00:00Z|   65.20464367   
...
This row should be deleted from the DataFrame because the date in the 'reports_at' column occurs after the date in the 'as_of' column
You need boolean indexing or query:
1.
df1 = df[df['as_of'] > df['reports_at']]
2.
df1 = df.query('as_of > reports_at')
3.
df1 = df[df['reports_at'] <= df['as_of']]
4.
df1 = df.query('reports_at <= as_of')
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With