Question: I have the following DataFrame:

```
Stint    Year   ID  Data1    Data2  Team
  1     2010    A    10       1      SFN
  1     2011    A    10       1      SFN
  1     2013    A    10       1      SFN
  2     2013    A    10       1      ATL
  1     1922    B    10       1      ARI
  1     1923    B    10       1      ARI
  1     1924    B    10       1      ARI

```

I'm trying to return a new DataFrame which sums up values in the Data1 and Data2 columns for identical years. I would like the DataFrame above to ultimately look like this:

```
    Year   ID  Data1    Data2 
    2010    A    10       1      
    2011    A    10       1         
    2013    A    20       2      
    1922    B    10       1      
    1923    B    10       1      
    1924    B    10       1      

```

I've messed around with some groupby functions, but I'm having trouble getting the proper DataFrame structure.

Thanks!

Answer: 
### `groupby` with `as_index=False`

Will not include grouped columns in a new index

```
df.groupby(['Year', 'ID'], as_index=False)[['Data1', 'Data2']].sum()

   Year ID  Data1  Data2
0  1922  B     10      1
1  1923  B     10      1
2  1924  B     10      1
3  2010  A     10      1
4  2011  A     10      1
5  2013  A     20      2

```
**`groupby` with `sort=false`**

Also, if you like to keep your data in the same Year format ie. [2010,2011,2013,1922,1923,1924], you can check 'sort=False' 
so the same code can be written with the sort values set to false as:

```
df.groupby(['Year', 'ID'], as_index= False, sort= False)[['Data1', 'Data2']].sum()

```