Stop concat from attempting to sort mismatched columns by default (#2… · pandas-dev/pandas@c4da79b (original) (raw)

`@@ -20,7 +20,7 @@

`

20

20

``

21

21

`def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,

`

22

22

`keys=None, levels=None, names=None, verify_integrity=False,

`

23

``

`-

copy=True):

`

``

23

`+

sort=None, copy=True):

`

24

24

`"""

`

25

25

` Concatenate pandas objects along a particular axis with optional set logic

`

26

26

` along the other axes.

`

`@@ -60,6 +60,19 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,

`

60

60

` verify_integrity : boolean, default False

`

61

61

` Check whether the new concatenated axis contains duplicates. This can

`

62

62

` be very expensive relative to the actual data concatenation

`

``

63

`+

sort : boolean, default None

`

``

64

`` +

Sort non-concatenation axis if it is not already aligned when join

``

``

65

`+

is 'outer'. The current default of sorting is deprecated and will

`

``

66

`+

change to not-sorting in a future version of pandas.

`

``

67

+

``

68


 Explicitly pass ``sort=True`` to silence the warning and sort.

``

69


 Explicitly pass ``sort=False`` to silence the warning and not sort.

``

70

+

``

71


 This has no effect when ``join='inner'``, which already preserves

``

72

`+

the order of the non-concatenation axis.

`

``

73

+

``

74

`+

.. versionadded:: 0.23.0

`

``

75

+

63

76

` copy : boolean, default True

`

64

77

` If False, do not copy data unnecessarily

`

65

78

``

`@@ -209,7 +222,7 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,

`

209

222

`ignore_index=ignore_index, join=join,

`

210

223

`keys=keys, levels=levels, names=names,

`

211

224

`verify_integrity=verify_integrity,

`

212

``

`-

copy=copy)

`

``

225

`+

copy=copy, sort=sort)

`

213

226

`return op.get_result()

`

214

227

``

215

228

``

`@@ -220,7 +233,8 @@ class _Concatenator(object):

`

220

233

``

221

234

`def init(self, objs, axis=0, join='outer', join_axes=None,

`

222

235

`keys=None, levels=None, names=None,

`

223

``

`-

ignore_index=False, verify_integrity=False, copy=True):

`

``

236

`+

ignore_index=False, verify_integrity=False, copy=True,

`

``

237

`+

sort=False):

`

224

238

`if isinstance(objs, (NDFrame, compat.string_types)):

`

225

239

`raise TypeError('first argument must be an iterable of pandas '

`

226

240

`'objects, you passed an object of type '

`

`@@ -355,6 +369,7 @@ def init(self, objs, axis=0, join='outer', join_axes=None,

`

355

369

`self.keys = keys

`

356

370

`self.names = names or getattr(keys, 'names', None)

`

357

371

`self.levels = levels

`

``

372

`+

self.sort = sort

`

358

373

``

359

374

`self.ignore_index = ignore_index

`

360

375

`self.verify_integrity = verify_integrity

`

`@@ -447,7 +462,8 @@ def _get_comb_axis(self, i):

`

447

462

`data_axis = self.objs[0]._get_block_manager_axis(i)

`

448

463

`try:

`

449

464

`return _get_objs_combined_axis(self.objs, axis=data_axis,

`

450

``

`-

intersect=self.intersect)

`

``

465

`+

intersect=self.intersect,

`

``

466

`+

sort=self.sort)

`

451

467

`except IndexError:

`

452

468

`types = [type(x).name for x in self.objs]

`

453

469

`raise TypeError("Cannot concatenate list of {types}"

`