Skip to content

Commit

Permalink
Review (jreback)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Aug 22, 2018
1 parent d9122d4 commit 5294371
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
7 changes: 4 additions & 3 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6507,9 +6507,10 @@ def _join_compat(self, other, on=None, how='left', lsuffix='', rsuffix='',
# join indexes only using concat
if can_concat:
if how == 'left':
how = 'outer'
return concat(frames, axis=1, join=how,
verify_integrity=True).reindex(self.index)
res = concat(frames, axis=1, join='outer',
verify_integrity=True, copy=False)
res = res.reindex(self.index, copy=False)
return res
else:
return concat(frames, axis=1, join=how,
verify_integrity=True)
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8931,7 +8931,8 @@ def describe_1d(data):
if name not in names:
names.append(name)

d = pd.concat([x.reindex(names) for x in ldesc], axis=1, sort=False)
d = pd.concat([x.reindex(names) for x in ldesc], axis=1,
sort=False, copy=False)
d.columns = data.columns.copy()
return d

Expand Down
7 changes: 4 additions & 3 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,11 @@ def _transform_general(self, func, *args, **kwargs):
applied.append(res)

concat_index = obj.columns if self.axis == 0 else obj.index
other_axis = (self.axis + 1) % 2 # switches from 0 to 1 or from 1 to 0
other_axis = 1 if self.axis == 0 else 0 # switches between 0 & 1
concatenated = concat(applied, axis=self.axis,
verify_integrity=False).reindex(concat_index,
axis=other_axis)
verify_integrity=False, copy=False)
concatenated = concatenated.reindex(concat_index, axis=other_axis,
copy=False)
return self._set_result_index_ordered(concatenated)

@Substitution(klass='DataFrame', selected='')
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,
if join_axes is not None:
warnings.warn('The join_axes-keyword is deprecated. Use .reindex or '
'.reindex_like on the result to achieve the same '
'functionality, or apply those methods to the inputs if '
'performance-sensitive.', FutureWarning, stacklevel=2)
'functionality.', FutureWarning, stacklevel=2)
op = _Concatenator(objs, axis=axis, join_axes=join_axes,
ignore_index=ignore_index, join=join,
keys=keys, levels=levels, names=names,
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/reshape/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,8 @@ def test_concat_categorical_empty(self):
tm.assert_series_equal(pd.concat([s2, s1], ignore_index=True), exp)
tm.assert_series_equal(s2.append(s1, ignore_index=True), exp)

def test_concat_join_axes(self, axis):
def test_concat_join_axes_deprecated(self, axis):
# GH21951
one = pd.DataFrame([[0., 1.], [2., 3.]], columns=list('ab'))
two = pd.DataFrame([[10., 11.], [12., 13.]], index=[1, 2],
columns=list('bc'))
Expand Down

0 comments on commit 5294371

Please sign in to comment.