Skip to content

Commit eaec953

Browse files
committed
BUG: (GH3481) revised, fix concat to allow a passed generator as the single arg
(also list/tuple/dict)
1 parent 6cd4adc commit eaec953

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Diff for: RELEASE.rst

+2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ pandas 0.11.1
214214
- Groupby transform with item-by-item not upcasting correctly (GH3740_)
215215
- Incorrectly read a HDFStore multi-index Frame witha column specification (GH3748_)
216216
- ``read_html`` now correctly skips tests (GH3741_)
217+
- Fix incorrect arguments passed to concat that are not list-like (e.g. concat(df1,df2)) (GH3481_)
217218

218219
.. _GH3164: https://github.com/pydata/pandas/issues/3164
219220
.. _GH2786: https://github.com/pydata/pandas/issues/2786
@@ -225,6 +226,7 @@ pandas 0.11.1
225226
.. _GH3251: https://github.com/pydata/pandas/issues/3251
226227
.. _GH3379: https://github.com/pydata/pandas/issues/3379
227228
.. _GH3480: https://github.com/pydata/pandas/issues/3480
229+
.. _GH3481: https://github.com/pydata/pandas/issues/3481
228230
.. _GH2852: https://github.com/pydata/pandas/issues/2852
229231
.. _GH3100: https://github.com/pydata/pandas/issues/3100
230232
.. _GH3454: https://github.com/pydata/pandas/issues/3454

Diff for: pandas/tools/merge.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import itertools
66
import numpy as np
7-
7+
import types
88
from pandas.core.categorical import Categorical
99
from pandas.core.frame import DataFrame, _merge_doc
1010
from pandas.core.generic import NDFrame
@@ -888,11 +888,11 @@ class _Concatenator(object):
888888
def __init__(self, objs, axis=0, join='outer', join_axes=None,
889889
keys=None, levels=None, names=None,
890890
ignore_index=False, verify_integrity=False):
891-
if not isinstance(objs, (tuple, list, dict)):
892-
raise AssertionError('first argument must be a list of pandas '
891+
if not isinstance(objs, (list,tuple,types.GeneratorType,dict)):
892+
raise AssertionError('first argument must be a list-like of pandas '
893893
'objects, you passed an object of type '
894894
'"{0}"'.format(type(objs).__name__))
895-
895+
896896
if join == 'outer':
897897
self.intersect = False
898898
elif join == 'inner':

Diff for: pandas/tools/tests/test_merge.py

+3
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,9 @@ def test_concat_invalid_first_argument(self):
17091709
df2 = mkdf(10, 2)
17101710
self.assertRaises(AssertionError, concat, df1, df2)
17111711

1712+
# generator ok though
1713+
concat(DataFrame(np.random.rand(5,5)) for _ in range(3))
1714+
17121715
class TestOrderedMerge(unittest.TestCase):
17131716

17141717
def setUp(self):

0 commit comments

Comments
 (0)