Skip to content

Mean/Std of multi-columns+rows #9197

Answered by cpcloud
iamgp asked this question in Q&A
Discussion options

You must be logged in to vote

You can do this with group_by, but you need to pivot the data into a longer form first:

In [60]: from ibis.interactive import *

In [61]: data
Out[61]:
{'row_type': ['type1', 'type2', 'type1'],
 'quantity_1': [10, 20, 30],
 'quantity_2': [11, 21, 31],
 'quantity_3': [12, 22, 32]}

In [62]: t = ibis.memtable(data)

In [63]: t
Out[63]:
┏━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ row_type ┃ quantity_1 ┃ quantity_2 ┃ quantity_3 ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ string   │ int64      │ int64      │ int64      │
├──────────┼────────────┼────────────┼────────────┤
│ type1    │         10 │         11 │         12 │
│ type2    │         20 │         21 │         22…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cpcloud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants