Welcome to stackoverflow. Please be so kind as to review How to make good reproducible pandas examples before asking further questions on Pandas
As for your specific question, let's start with a simple example
import pandas as pd
df = pd.DataFrame({'bullish' : [True, True, True, True, False, False, True]})
Then we can split as such (note I think you got the shift(-1)
slightly wrong here)
df['split'] = df['bullish'] != df['bullish'].shift()
df
this produces
bullish split
0 True True
1 True False
2 True False
3 True False
4 False True
5 False False
6 True True
To achieve what you want you can use a combination of groupby
and cumsum
applied to the 'split'
column, like so:
for id, g in df.groupby(df['split'].cumsum()):
print(f'group_id = {id}')
print(g)
This will print three dataframes with the same 'bullish'
value inside each:
group_id = 1
bullish split
0 True True
1 True False
2 True False
3 True False
group_id = 2
bullish split
4 False True
5 False False
group_id = 3
bullish split
6 True True
Since you did not specify what output you actually wanted (another good practice on SO) I will leave it at that