1
1
# coding=utf-8
2
2
# pylint: disable-msg=E1101,W0612
3
3
4
+ import numpy as np
5
+ import pandas as pd
4
6
import pandas .util .testing as tm
5
7
6
8
@@ -32,6 +34,11 @@ def test_to_frame(self):
32
34
tm .assert_frame_equal (res , exp )
33
35
tm .assertIsInstance (res , tm .SubclassedDataFrame )
34
36
37
+
38
+ class TestSparseSeriesSubclassing (tm .TestCase ):
39
+
40
+ _multiprocess_can_split_ = True
41
+
35
42
def test_subclass_sparse_slice (self ):
36
43
s = tm .SubclassedSparseSeries ([1 , 2 , 3 , 4 , 5 ])
37
44
tm .assert_sp_series_equal (s .loc [1 :3 ],
@@ -53,5 +60,15 @@ def test_subclass_sparse_addition(self):
53
60
def test_subclass_sparse_to_frame (self ):
54
61
s = tm .SubclassedSparseSeries ([1 , 2 ], index = list ('abcd' ), name = 'xxx' )
55
62
res = s .to_frame ()
56
- exp = tm .SubclassedSparseDataFrame ({'xxx' : [1 , 2 ]}, index = list ('abcd' ))
63
+
64
+ exp_arr = pd .SparseArray ([1 , 2 ], dtype = np .int64 , kind = 'block' )
65
+ exp = tm .SubclassedSparseDataFrame ({'xxx' : exp_arr },
66
+ index = list ('abcd' ))
67
+ tm .assert_sp_frame_equal (res , exp )
68
+
69
+ s = tm .SubclassedSparseSeries ([1.1 , 2.1 ], index = list ('abcd' ),
70
+ name = 'xxx' )
71
+ res = s .to_frame ()
72
+ exp = tm .SubclassedSparseDataFrame ({'xxx' : [1.1 , 2.1 ]},
73
+ index = list ('abcd' ))
57
74
tm .assert_sp_frame_equal (res , exp )
0 commit comments