0

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html

This doc gives an example of groupby function:

l = [[1, 2, 3], [1, None, 4], [2, 1, 3], [1, 2, 2]]
df = pd.DataFrame(l, columns=["a", "b", "c"])

    a   b    c
0   1   2.0  3
1   1   NaN  4
2   2   1.0  3
3   1   2.0  2

 df.groupby(by=["b"]).sum()

  output:
         a   c
    b
    1.0  2   3
    2.0  2   5

I do not understand how the output like this?

Elizabeth Shen
  • 168
  • 2
  • 9

0 Answers0