- la.isaligned() returns True if two larrys are aligned along specified axis
- la.sortby() sorts 2d larry by the row or column corresponding to
given label element
isaligned example:
Make two 2d larrys that are aligned along columns but not rows:
>>> lar1 = larry([[1, 2], [3, 4]], [['row1', 'row2'], ['col1', 'col2']])
>>> lar2 = larry([[1, 2], [3, 4]], [['row2', 'row1'], ['col1', 'col2']])
The two larrys are not aligned:
>>> la.isaligned(lar1, lar2)
False
>>> la.isaligned(lar1, lar2, axis=0)
False
But the columns of the two larrys are aligned:
>>> la.isaligned(lar1, lar2, axis=1)
True
sortby example:
Create a larry:
>>> label = [['a','b'], ['c','d','e']]
>>> x = np.array([[1, 2, 3], [3, 1, 2]])
>>> lar = la.larry(x, label)
Sort larry by row 'b' along the first axis:
>>> la.sortby(lar, 'b', axis=0)
label_0
a
b
label_1
d
e
c
x
array([[2, 3, 1],
[1, 2, 3]])
Thanks for suggesting the sortby function.