Skip to content

Commit 4661525

Browse files
committed
Merge branch 'master' of https://github.com/mcsalgado/pandas into mcsalgado-master
2 parents 1781ee0 + 867b288 commit 4661525

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

doc/source/whatsnew/v0.15.2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Enhancements
7373
- ``Timedelta`` arithmetic returns ``NotImplemented`` in unknown cases, allowing extensions by custom classes (:issue:`8813`).
7474
- ``Timedelta`` now supports arithemtic with ``numpy.ndarray`` objects of the appropriate dtype (numpy 1.8 or newer only) (:issue:`8884`).
7575
- Added ``Timedelta.to_timedelta64`` method to the public API (:issue:`8884`).
76+
- ``Series`` now works with map objects the same way as generators (:issue:`8909`).
7677

7778
.. _whatsnew_0152.performance:
7879

pandas/core/series.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
183183
raise ValueError("cannot specify a dtype with a Categorical")
184184
if name is None:
185185
name = data.name
186-
elif isinstance(data, types.GeneratorType):
186+
elif (isinstance(data, types.GeneratorType) or
187+
(compat.PY3 and isinstance(data, map))):
187188
data = list(data)
188189
elif isinstance(data, (set, frozenset)):
189190
raise TypeError("{0!r} type is unordered"

pandas/tests/test_series.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,19 @@ def test_constructor_generator(self):
632632
exp.index = lrange(10, 20)
633633
assert_series_equal(result, exp)
634634

635+
def test_constructor_map(self):
636+
# GH8909
637+
m = map(lambda x: x, range(10))
638+
639+
result = Series(m)
640+
exp = Series(lrange(10))
641+
assert_series_equal(result, exp)
642+
643+
m = map(lambda x: x, range(10))
644+
result = Series(m, index=lrange(10, 20))
645+
exp.index = lrange(10, 20)
646+
assert_series_equal(result, exp)
647+
635648
def test_constructor_categorical(self):
636649
cat = pd.Categorical([0, 1, 2, 0, 1, 2], ['a', 'b', 'c'], fastpath=True)
637650
cat.name = 'foo'

0 commit comments

Comments
 (0)