Skip to content

Commit 04fba8d

Browse files
author
Carlos Souza
committed
Adding test_rename test cases (were missing)
1 parent 483bb2c commit 04fba8d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pandas/tests/sparse/test_frame.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,18 @@ def test_sparse_frame_fillna_limit(self):
767767
tm.assert_frame_equal(result, expected)
768768

769769
def test_rename(self):
770-
# just check this works
771-
rename = self.frame.rename(index=str) # noqa
772-
rename = self.frame.rename(
773-
columns=lambda x: '%s%d' % (x, len(x))) # noqa
770+
result = self.frame.rename(index=str)
771+
expected = SparseDataFrame(self.data, index=self.dates.strftime(
772+
"%Y-%m-%d %H:%M:%S"))
773+
tm.assert_sp_frame_equal(result, expected)
774+
775+
result = self.frame.rename(columns=lambda x: '%s%d' % (x, len(x)))
776+
data = {'A1': [nan, nan, nan, 0, 1, 2, 3, 4, 5, 6],
777+
'B1': [0, 1, 2, nan, nan, nan, 3, 4, 5, 6],
778+
'C1': np.arange(10, dtype=np.float64),
779+
'D1': [0, 1, 2, 3, 4, 5, nan, nan, nan, nan]}
780+
expected = SparseDataFrame(data, index=self.dates)
781+
tm.assert_sp_frame_equal(result, expected)
774782

775783
def test_corr(self):
776784
res = self.frame.corr()
@@ -1309,4 +1317,3 @@ def test_numpy_func_call(self):
13091317
'std', 'min', 'max']
13101318
for func in funcs:
13111319
getattr(np, func)(self.frame)
1312-

0 commit comments

Comments
 (0)