我在.csv中有'Season','HomeTeam','AwayTeam',我根据'Season'分组到列表中。我想数一下每个队的名字在多个列表中出现的次数。
使用:-
clubslist=(epl.groupby(['Season'])['HomeTeam', 'AwayTeam'].apply(lambda x: pd.unique(x.values.ravel()).tolist()))`
clubslist
I was able to get:-
Season
2000-01 [Charlton, Man City, Chelsea, West Ham, Covent...
2001-02 [Charlton, Everton, Derby, Blackburn, Leeds,...
2002-03 [Blackburn, Sunderland, Charlton, Chelsea, Everton...
2003-04 [Arsenal, Everton, Birmingham, Tottenham, Blackburn...
2004-05 [Aston Villa, Southampton, Blackburn, West Bro...
2005-06 [Aston Villa, Bolton, Everton, Man United, Ful...
.
.
.
.
All the way down to:-
2021-22 [Brentford, Arsenal, Man United, Leeds, Burnle...
So for example, based on above 7 Seasons, I want the output to be
Charlton: 3
Chelsea: 2
Everton: 4
Blackburn: 4
Aston Villa: 2
Arsenal: 2
Sunderland: 1
Derby: 1
and so on and so forth.
1条答案
按热度按时间4bbkushb1#
执行: