Nov-08-2021, 10:16 PM
I figured out the problem!
It is described here: https://cumsum.wordpress.com/2021/05/05/...type-bool/
Simply, the expression is interpreted with priority to the "|" - so in my example, it will look to see if the first letter is equal to A or equal to the rest of the expression. Hope this makes sense to anyone looking for the same.
I fixed it like this - simply adding two sets of parentheses:
sorted = rawdata[(rawdata['Ticker'].astype(str).str[0] =="A") | (rawdata['Ticker'].astype(str).str[0] =="B")]
It is described here: https://cumsum.wordpress.com/2021/05/05/...type-bool/
Simply, the expression is interpreted with priority to the "|" - so in my example, it will look to see if the first letter is equal to A or equal to the rest of the expression. Hope this makes sense to anyone looking for the same.
I fixed it like this - simply adding two sets of parentheses:
sorted = rawdata[(rawdata['Ticker'].astype(str).str[0] =="A") | (rawdata['Ticker'].astype(str).str[0] =="B")]