|
8 | 8 |
|
9 | 9 | from pandas import Series, DataFrame
|
10 | 10 |
|
11 |
| -from pandas.compat import StringIO, u |
| 11 | +from pandas.compat import StringIO, u, long |
12 | 12 | from pandas.util.testing import (assert_series_equal, assert_almost_equal,
|
13 | 13 | assert_frame_equal, ensure_clean)
|
14 | 14 | import pandas.util.testing as tm
|
@@ -82,16 +82,6 @@ def test_to_csv_unicode_index(self):
|
82 | 82 |
|
83 | 83 | assert_series_equal(s, s2)
|
84 | 84 |
|
85 |
| - def test_tolist(self): |
86 |
| - rs = self.ts.tolist() |
87 |
| - xp = self.ts.values.tolist() |
88 |
| - assert_almost_equal(rs, xp) |
89 |
| - |
90 |
| - # datetime64 |
91 |
| - s = Series(self.ts.index) |
92 |
| - rs = s.tolist() |
93 |
| - self.assertEqual(self.ts.index[0], rs[0]) |
94 |
| - |
95 | 85 | def test_to_frame(self):
|
96 | 86 | self.ts.name = None
|
97 | 87 | rs = self.ts.to_frame()
|
@@ -174,3 +164,39 @@ class SubclassedFrame(DataFrame):
|
174 | 164 | self.assertTrue(isinstance(result, SubclassedFrame))
|
175 | 165 | expected = SubclassedFrame({'X': [1, 2, 3]})
|
176 | 166 | assert_frame_equal(result, expected)
|
| 167 | + |
| 168 | + |
| 169 | +class TestSeriesToList(TestData, tm.TestCase): |
| 170 | + |
| 171 | + _multiprocess_can_split_ = True |
| 172 | + |
| 173 | + def test_tolist(self): |
| 174 | + rs = self.ts.tolist() |
| 175 | + xp = self.ts.values.tolist() |
| 176 | + assert_almost_equal(rs, xp) |
| 177 | + |
| 178 | + # datetime64 |
| 179 | + s = Series(self.ts.index) |
| 180 | + rs = s.tolist() |
| 181 | + self.assertEqual(self.ts.index[0], rs[0]) |
| 182 | + |
| 183 | + def test_tolist_np_int(self): |
| 184 | + # GH10904 |
| 185 | + for t in ['int8', 'int16', 'int32', 'int64']: |
| 186 | + s = pd.Series([1], dtype=t) |
| 187 | + self.assertIsInstance(s.tolist()[0], int) |
| 188 | + |
| 189 | + def test_tolist_np_uint(self): |
| 190 | + # GH10904 |
| 191 | + for t in ['uint8', 'uint16']: |
| 192 | + s = pd.Series([1], dtype=t) |
| 193 | + self.assertIsInstance(s.tolist()[0], int) |
| 194 | + for t in ['uint32', 'uint64']: |
| 195 | + s = pd.Series([1], dtype=t) |
| 196 | + self.assertIsInstance(s.tolist()[0], long) |
| 197 | + |
| 198 | + def test_tolist_np_float(self): |
| 199 | + # GH10904 |
| 200 | + for t in ['float16', 'float32', 'float64']: |
| 201 | + s = pd.Series([1], dtype=t) |
| 202 | + self.assertIsInstance(s.tolist()[0], float) |
0 commit comments