|
17 | 17 | from larray import (LArray, Axis, LGroup, union, zeros, zeros_like, ndrange, ndtest, ones, eye, diag, stack, |
18 | 18 | clip, exp, where, X, mean, isnan, round, read_hdf, read_csv, read_eurostat, read_excel, |
19 | 19 | from_lists, from_string, open_excel, from_frame, sequence, nan_equal) |
| 20 | +from larray.inout.array import from_series |
20 | 21 | from larray.core.axis import _to_ticks, _to_key |
21 | 22 | from larray.util.misc import StringIO |
22 | 23 |
|
@@ -2680,6 +2681,17 @@ def test_from_lists(self): |
2680 | 2681 | ['F', 'FO', 0, 0, 2]], sort_columns=True) |
2681 | 2682 | assert_array_equal(sorted_arr, arr) |
2682 | 2683 |
|
| 2684 | + def test_from_series(self): |
| 2685 | + expected = ndtest(3) |
| 2686 | + s = pd.Series([0, 1, 2], index=pd.Index(['a0', 'a1', 'a2'], name='a')) |
| 2687 | + assert_array_equal(from_series(s), expected) |
| 2688 | + |
| 2689 | + s = pd.Series([2, 0, 1], index=pd.Index(['a2', 'a0', 'a1'], name='a')) |
| 2690 | + assert_array_equal(from_series(s, sort_rows=True), expected) |
| 2691 | + |
| 2692 | + expected = ndtest(3)[['a2', 'a0', 'a1']] |
| 2693 | + assert_array_equal(from_series(s), expected) |
| 2694 | + |
2683 | 2695 | def test_from_frame(self): |
2684 | 2696 | # 1) data = scalar |
2685 | 2697 | # ================ |
|
0 commit comments