Skip to content

Commit

Permalink
ENH: test suite passes, deleted old join code, #220, #249, #267 complete
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Dec 30, 2011
1 parent 65de156 commit 262be79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 43 deletions.
29 changes: 0 additions & 29 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,35 +825,6 @@ def _is_indexed_like(self, other):
return False
return True

def join_on(self, other, on, how='left', axis=1, lsuffix=None,
rsuffix=None):
this, other = self._maybe_rename_join(other, lsuffix, rsuffix)

other_axis = other.axes[axis]
indexer = other_axis.get_indexer(on)

if how == 'left':
mask = indexer == -1
needs_masking = len(on) > 0 and mask.any()
else:
mask = indexer != -1
this = this.take(mask.nonzero()[0], axis=axis)
indexer = indexer[mask]
mask = None
needs_masking = False

other_blocks = []
for block in other.blocks:
newb = block.reindex_axis(indexer, mask, needs_masking, axis=axis)
other_blocks.append(newb)

cons_items = this.items + other.items
consolidated = _consolidate(this.blocks + other_blocks, cons_items)

new_axes = list(this.axes)
new_axes[0] = cons_items
return BlockManager(consolidated, new_axes)

def rename_axis(self, mapper, axis=1):
new_axis = Index([mapper(x) for x in self.axes[axis]])
new_axis._verify_integrity()
Expand Down
27 changes: 13 additions & 14 deletions pandas/tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@ def merge(left, right, how='left', on=None, left_on=None, right_on=None,
* outer: use union of keys from both frames (SQL: full outer join)
* inner: use intersection of keys from both frames (SQL: inner join)
on : label or list
Field names to join on. Must be found in both DataFrames
left_on : label or list
Field names to join on in left DataFrame
right_on : label or list
Field names to join on in right DataFrame
Field names to join on. Must be found in both DataFrames.
left_on : label or list, or array-like
Field names to join on in left DataFrame. Can be a vector or list of
vectors of the length of the DataFrame to use a particular vector as
the join key instead of columns
right_on : label or list, or array-like
Field names to join on in right DataFrame or vector/list of vectors per
left_on docs
left_index : boolean, default True
Use the index from the left DataFrame as the join key
Use the index from the left DataFrame as the join key(s). If it is a
MultiIndex, the number of keys in the other DataFrame (either the index
or a number of columns) must match the number of levels
right_index : boolean, default True
Use the index from the right DataFrame as the join key
Use the index from the right DataFrame as the join key. Same caveats as
left_index
sort : boolean, default True
Sort the join keys lexicographically in the result DataFrame
suffixes : 2-length sequence (tuple, list, ...)
Expand All @@ -64,13 +70,6 @@ def merge(left, right, how='left', on=None, left_on=None, right_on=None,
# TODO: transformations??
# TODO: only copy DataFrames when modification necessary

# def join_managers(left, right, axis=1, how='left', copy=True):
# join_index, left_indexer, right_indexer = \
# left.axes[axis].join(right.axes[axis], how=how, return_indexers=True)
# op = _BlockJoinOperation(left, right, join_index, left_indexer,
# right_indexer, axis=axis)
# return op.get_result(copy=copy)

class _MergeOperation(object):
"""
Expand Down

0 comments on commit 262be79

Please sign in to comment.