Skip to content

Commit b66dc9c

Browse files
committed
BUG: fix error after Panel truncate copy close #1823
1 parent cfd2005 commit b66dc9c

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

RELEASE.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ pandas 0.9.0
120120
- Fix unicode console encoding issue in IPython notebook (#1782, #1768)
121121
- Fix unicode formatting issue with Series.name (#1782)
122122
- Fix bug in DataFrame.duplicated with datetime64 columns (#1833)
123+
- Fix bug in Panel internals resulting in error when doing fillna after
124+
truncate not changing size of panel (#1823)
123125

124126
pandas 0.8.1
125127
============

pandas/core/internals.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,12 @@ def reindex_axis(self, new_axis, method=None, axis=0, copy=True):
949949
if copy:
950950
result = self.copy(deep=True)
951951
result.axes[axis] = new_axis
952+
953+
if axis == 0:
954+
# patch ref_items
955+
for blk in result.blocks:
956+
blk.ref_items = new_axis
957+
952958
return result
953959
else:
954960
return self

pandas/tests/test_panel.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,13 @@ def test_fillna(self):
897897
filled = empty.fillna(0)
898898
assert_panel_equal(filled, empty)
899899

900+
def test_truncate_fillna_bug(self):
901+
# #1823
902+
result = self.panel.truncate(before=None, after=None, axis='items')
903+
904+
# it works!
905+
result.fillna(value=0.0)
906+
900907
def test_swapaxes(self):
901908
result = self.panel.swapaxes('items', 'minor')
902909
self.assert_(result.items is self.panel.minor_axis)

0 commit comments

Comments
 (0)