How would you call this operation? how would you e...
# present-company
m
How would you call this operation? how would you express it abstractly and if you know, how would you express it in a language that can do it? (I know the general operation is called transpose, but here I'm transposing a subset)
🤔 1
g
isn’t that called a “pivot table”
âž• 2
there usual isn’t reverse operation because the amounts can be aggregated. example if you had two rows
Copy code
AR, Q1, 5
AR, Q1, 6
The pivot would have one cell to hold both values.
m
In pandas and R they are pivot and melt, in SQL they seem to be pivot and unpivot
a
This seems to rely on redundancy in the second source column for its well-definedness, or at least its meaningfulness. If I really wanted to be picky about it, I would project it entirely into (country, period, number) tuples and then try fitting it into another table shape.
Reading further, it seems like the special case of a pivot that kinda looks like a transpose is one where you require that there be exactly one item in each "aggregated" field, and then don't actually aggregate. Is that right?
m
@Andrew F yes, it a subset of pivot
w
Over here we call it pivoting including the special case where you don't do any aggregation. There are many ways to pivot. Swapping rows and columns is transposing. Removing a field means that you're going to marginalize or aggregate over it.