Closed freekeys closed 3 years ago
Hi,
I am not a total Pandas wizard myself, but I think you have to adjust two things: reset the index on all masks and use boolean indexing on the dataframe that you want to filter. So something like:
date_limit = datetime.now() - timedelta(days=90)
mask_date_limit = (df_all_signals.reset_index()[DATE] == date_limit)
mask = (df_all_signals.reset_index()[CURRENT_RATIO] > mask_current_ratio)
mask &= (df_all_signals.reset_index()[ROE] > mask_roe)
mask &= mask_date_limit
df_filtered = df_all_signals[mask.tolist()]
Let me know if this worked.
closing this - pls open a new issue if you still have problems.
Hello,
Sorry if this is a basic question! I have a MultiIndex df similar to the one in the Screener tutorial. I want to add a date mask for when
Date == current_date
. Where current date is for examplecurrent_date = datetime.datetime(2020, 7, 28)
Similarly, I'd also like to do the same but with a Ticker filter too. So
Date == current_date
andTicker == 'AAPL'
for example.When I try setting this up I am struggling with different errors. I've tried a few things. Could you point me in the right direction please? Many thanks!
Here's what I've tried: