static-frame
static-frame copied to clipboard
Grouping and aggregating should be easy (possibly even for idiots like me)
Description
I want to like SF, I really do, it's conceptually awesome. But I'm finding it almost impossible to actually use.
I'm not sure if this is because: a) I'm an idiot; b) lack of documentation; or c) a user-unfriendly API.
It's true, every class, attribute, and method does seem to have some kind of documentation, but:
- arguments to functions are often undocumented and not always obvious from their names.
- the examples given typically only show basic usage (in the API docs, quickstart guide, notebook examples).
Perhaps if there was a community slack channel to ask for help?
I'm assuming I can't be the only (idiot) who is ready to give up and go back to flawed but easy-to-use Pandas...
Example
I've spent around 4 hours trying to implement the below very simple Pandas code using SF. My main angle of attack was trying to use Frame.iter_group*
. I got as far as getting it to show me frames for each grouping on column a
but could not figure out how to make it aggregate with different functions for each column.
df = pd.DataFrame({
"a": [1, 2, 2, 3],
"b": [4, 2, 3, 6],
"c": [1, 2, 3, 3]
})
df = df.groupby(["a"]).agg({"b": "sum", "c": "min"})
# b c
# a
# 1 4 1
# 2 5 2
# 3 6 3