79587188

Date: 2025-04-22 18:19:37
Score: 3.5
Natty:
Report link

Thank you to all that responded. I did try doing all the filtering outside of polars but it turned out to be really un wieldy, which is why I was trying to do it in Polars. When I thought about it some more I realised that some of the filtering was not required. But in the end I came up with a solution, as follows:

self.configs_df = self.configs_df.filter(
       ((pl.col('Ticker') == ticker) | (pl.lit(ticker) == pl.lit('')))
       & ((pl.col('Iteration') == iteration) | (pl.lit(iteration) == pl.lit(-1)))
)

I think the original problem was that I was trying to do something like this:

(ticker != '' & ...

which is what other people suggested. I think the trick was to use

pl.lit(ticker) == pl.lit('')

instead. So, I managed to resolve my problem, and I hope this helps anyone else that may have a similar problem. Thanks all that contributed.

Regards, Stuart

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (1): Regards
  • Whitelisted phrase (-1): hope this helps
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): have a similar problem
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: StuartM