I have some data that looks like this:
Season Team TEAM_ID start end
0 1984-85 CHI 1610612741 1984 1985
1 1985-86 CHI 1610612741 1985 1986
2 1986-87 CHI 1610612741 1986 1987
3 1987-88 CHI 1610612741 1987 1988
4 1988-89 CHI 1610612741 1988 1989
5 1989-90 CHI 1610612741 1989 1990
6 1990-91 CHI 1610612741 1990 1991
7 1991-92 CHI 1610612741 1991 1992
8 1992-93 CHI 1610612741 1992 1993
9 1994-95 CHI 1610612741 1994 1995
10 1995-96 CHI 1610612741 1995 1996
11 1996-97 CHI 1610612741 1996 1997
12 1997-98 CHI 1610612741 1997 1998
13 2001-02 WAS 1610612764 2001 2002
14 2002-03 WAS 1610612764 2002 2003
I'm looking for a way to group the team and team id columns together and get the minimum start value and maximum end column. For the above data, it would be
Team TEAM_ID Years
CHI 1610612741 1984-93
CHI 1610612741 1994-98
WAS 1610612764 2001-03
For someone that has multiple teams in one year,
Season Team TEAM_ID start end
0 2003-04 MIA 1610612748 2003 2004
1 2004-05 MIA 1610612748 2004 2005
2 2005-06 MIA 1610612748 2005 2006
3 2006-07 MIA 1610612748 2006 2007
4 2007-08 MIA 1610612748 2007 2008
5 2008-09 MIA 1610612748 2008 2009
6 2009-10 MIA 1610612748 2009 2010
7 2010-11 MIA 1610612748 2010 2011
8 2011-12 MIA 1610612748 2011 2012
9 2012-13 MIA 1610612748 2012 2013
10 2013-14 MIA 1610612748 2013 2014
11 2014-15 MIA 1610612748 2014 2015
12 2015-16 MIA 1610612748 2015 2016
13 2016-17 CHI 1610612741 2016 2017
14 2017-18 CLE 1610612739 2017 2018
15 2017-18 MIA 1610612748 2017 2018
17 2018-19 MIA 1610612748 2018 2019
I'd like it to look like this:
Team TEAM_ID Years
MIA 1610612748 2003-16
CHI 1610612741 2016-17
CLE 1610612739 2017-17
MIA 1610612748 2017-19
Does anyone know how to do that? I tried using pandas.group_by but it would group the same teams together as one and I'd like to keep them separate