I have a dataframe as this:
HOME_TEAM AWAY_TEAM BOOL
1153 Manchester United Swansea City True
1163 Leicester City Everton False
1172 Everton Hull City True
1183 Stoke City Everton True
1193 West Bromwich Albion Sunderland False
I want groups for each team that appears in HOME_TEAM or AWAY_TEAM. For example, for Everton, I would like something similar as a result:
HOME_TEAM AWAY_TEAM BOOL
1163 Leicester City Everton False
1172 Everton Hull City True
1183 Stoke City Everton True
then I have to count the consecutive True of False, but this is not a problem. The problem is groups the matches in this way.
I know I can simply use
(df.HOME_TEAM == 'Everton') | (df.AWAY_TEAM == 'Everton)
but this way I should use a for loop for each team in my dataframe and it is too slow for my big dataframe.