Skip to content

Commit 262be79

Browse files
committed
ENH: test suite passes, deleted old join code, #220, #249, #267 complete
1 parent 65de156 commit 262be79

File tree

2 files changed

+13
-43
lines changed

2 files changed

+13
-43
lines changed

pandas/core/internals.py

-29
Original file line numberDiff line numberDiff line change
@@ -825,35 +825,6 @@ def _is_indexed_like(self, other):
825825
return False
826826
return True
827827

828-
def join_on(self, other, on, how='left', axis=1, lsuffix=None,
829-
rsuffix=None):
830-
this, other = self._maybe_rename_join(other, lsuffix, rsuffix)
831-
832-
other_axis = other.axes[axis]
833-
indexer = other_axis.get_indexer(on)
834-
835-
if how == 'left':
836-
mask = indexer == -1
837-
needs_masking = len(on) > 0 and mask.any()
838-
else:
839-
mask = indexer != -1
840-
this = this.take(mask.nonzero()[0], axis=axis)
841-
indexer = indexer[mask]
842-
mask = None
843-
needs_masking = False
844-
845-
other_blocks = []
846-
for block in other.blocks:
847-
newb = block.reindex_axis(indexer, mask, needs_masking, axis=axis)
848-
other_blocks.append(newb)
849-
850-
cons_items = this.items + other.items
851-
consolidated = _consolidate(this.blocks + other_blocks, cons_items)
852-
853-
new_axes = list(this.axes)
854-
new_axes[0] = cons_items
855-
return BlockManager(consolidated, new_axes)
856-
857828
def rename_axis(self, mapper, axis=1):
858829
new_axis = Index([mapper(x) for x in self.axes[axis]])
859830
new_axis._verify_integrity()

pandas/tools/merge.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,21 @@ def merge(left, right, how='left', on=None, left_on=None, right_on=None,
3030
* outer: use union of keys from both frames (SQL: full outer join)
3131
* inner: use intersection of keys from both frames (SQL: inner join)
3232
on : label or list
33-
Field names to join on. Must be found in both DataFrames
34-
left_on : label or list
35-
Field names to join on in left DataFrame
36-
right_on : label or list
37-
Field names to join on in right DataFrame
33+
Field names to join on. Must be found in both DataFrames.
34+
left_on : label or list, or array-like
35+
Field names to join on in left DataFrame. Can be a vector or list of
36+
vectors of the length of the DataFrame to use a particular vector as
37+
the join key instead of columns
38+
right_on : label or list, or array-like
39+
Field names to join on in right DataFrame or vector/list of vectors per
40+
left_on docs
3841
left_index : boolean, default True
39-
Use the index from the left DataFrame as the join key
42+
Use the index from the left DataFrame as the join key(s). If it is a
43+
MultiIndex, the number of keys in the other DataFrame (either the index
44+
or a number of columns) must match the number of levels
4045
right_index : boolean, default True
41-
Use the index from the right DataFrame as the join key
46+
Use the index from the right DataFrame as the join key. Same caveats as
47+
left_index
4248
sort : boolean, default True
4349
Sort the join keys lexicographically in the result DataFrame
4450
suffixes : 2-length sequence (tuple, list, ...)
@@ -64,13 +70,6 @@ def merge(left, right, how='left', on=None, left_on=None, right_on=None,
6470
# TODO: transformations??
6571
# TODO: only copy DataFrames when modification necessary
6672

67-
# def join_managers(left, right, axis=1, how='left', copy=True):
68-
# join_index, left_indexer, right_indexer = \
69-
# left.axes[axis].join(right.axes[axis], how=how, return_indexers=True)
70-
# op = _BlockJoinOperation(left, right, join_index, left_indexer,
71-
# right_indexer, axis=axis)
72-
# return op.get_result(copy=copy)
73-
7473
class _MergeOperation(object):
7574
"""
7675

0 commit comments

Comments
 (0)