apply
applies the function to each group (your Species
). Your function returns 1, so you end up with 1 value for each of 3 groups.
agg
aggregates each column (feature) for each group, so you end up with one value per column per group.
Do read the groupby
docs, they’re quite helpful. There are also a bunch of tutorials floating around the web.