Skip to content

Commit 8db7b4d

Browse files
committed
Merge pull request #3205 from jreback/tests_fix
TST: fix tests in master
2 parents 3ea0dd9 + b15655b commit 8db7b4d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

pandas/sparse/frame.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,23 @@ def _set_columns(self, cols):
329329
if len(cols) != len(self._series):
330330
raise Exception('Columns length %d did not match data %d!' %
331331
(len(cols), len(self._series)))
332-
self._columns = _ensure_index(cols)
332+
333+
cols = _ensure_index(cols)
334+
335+
# rename the _series if needed
336+
existing = getattr(self,'_columns',None)
337+
if existing is not None and len(existing) == len(cols):
338+
339+
new_series = {}
340+
for i, col in enumerate(existing):
341+
new_col = cols[i]
342+
if new_col in new_series: # pragma: no cover
343+
raise Exception('Non-unique mapping!')
344+
new_series[new_col] = self._series.get(col)
345+
346+
self._series = new_series
347+
348+
self._columns = cols
333349

334350
index = property(fget=_get_index, fset=_set_index)
335351
columns = property(fget=_get_columns, fset=_set_columns)
@@ -619,7 +635,7 @@ def _reindex_with_indexers(self, index, row_indexer, columns, col_indexer,
619635

620636
def _rename_index_inplace(self, mapper):
621637
self.index = [mapper(x) for x in self.index]
622-
638+
623639
def _rename_columns_inplace(self, mapper):
624640
new_series = {}
625641
new_columns = []

pandas/tseries/period.py

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ def __eq__(self, other):
136136
raise TypeError(other)
137137
return False
138138

139+
def __ne__(self, other):
140+
return not self.__eq__(other)
141+
139142
def __hash__(self):
140143
return hash((self.ordinal, self.freq))
141144

0 commit comments

Comments
 (0)