Skip to content

Issue #806 DataFrame/Series.align can now specify fill_value or fill_method #807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 23, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TST: test coverage
  • Loading branch information
wesm committed Feb 9, 2012
commit 2546ac784d4733d0e2f2ecff386e55072ff238db
21 changes: 7 additions & 14 deletions pandas/sparse/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,26 +408,16 @@ def xs(self, key, axis=0, copy=False):
# Arithmetic-related methods

def _combine_frame(self, other, func, fill_value=None, level=None):
new_index = self.index.union(other.index)
new_columns = self.columns.union(other.columns)
this, other = self.align(other, join='outer', level=level,
copy=False)
new_index, new_columns = this.index, this.columns

if fill_value is not None or level is not None:
raise NotImplementedError

this = self
if self.index is not new_index:
this = self.reindex(new_index)
other = other.reindex(new_index)

if not self and not other:
return SparseDataFrame(index=new_index)

if not other:
return self * nan

if not self:
return other * nan

new_data = {}
for col in new_columns:
if col in this and col in other:
Expand Down Expand Up @@ -535,7 +525,10 @@ def _reindex_with_indexers(self, index, row_indexer, columns, col_indexer,
for col in columns:
if col not in self:
continue
new_arrays[col] = com.take_1d(self[col].values, row_indexer)
if row_indexer is not None:
new_arrays[col] = com.take_1d(self[col].values, row_indexer)
else:
new_arrays[col] = self[col]

return self._constructor(new_arrays, index=index, columns=columns)

Expand Down
4 changes: 2 additions & 2 deletions pandas/sparse/tests/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,10 @@ def test_op_corners(self):
self.assert_(not empty)

foo = self.frame + self.empty
assert_sp_frame_equal(foo, self.frame * np.nan)
assert_frame_equal(foo, self.frame * np.nan)

foo = self.empty + self.frame
assert_sp_frame_equal(foo, self.frame * np.nan)
assert_frame_equal(foo, self.frame * np.nan)

def test_scalar_ops(self):
pass
Expand Down