Skip to content

Commit a2ace52

Browse files
committed
add doc
1 parent 21f4b66 commit a2ace52

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Other Enhancements
179179
- :class:`IntervalIndex` has gained the :meth:`~IntervalIndex.set_closed` method to change the existing ``closed`` value (:issue:`21670`)
180180
- :func:`~DataFrame.to_csv` and :func:`~DataFrame.to_json` now support ``compression='infer'`` to infer compression based on filename (:issue:`15008`)
181181
- :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`)
182-
-
182+
- :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`)
183183

184184
.. _whatsnew_0240.api_breaking:
185185

pandas/core/frame.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class DataFrame(NDFrame):
267267
268268
Parameters
269269
----------
270-
data : numpy ndarray (structured or homogeneous), dict, or DataFrame
270+
data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame
271271
Dict can contain Series, arrays, constants, or list-like objects
272272
273273
.. versionchanged :: 0.23.0
@@ -391,6 +391,8 @@ def __init__(self, data=None, index=None, columns=None, dtype=None,
391391
else:
392392
mgr = self._init_ndarray(data, index, columns, dtype=dtype,
393393
copy=copy)
394+
395+
# For data is list-like, or Iterable (will consume into list)
394396
elif (isinstance(data, collections.Iterable)
395397
and not isinstance(data, string_and_binary_types)):
396398
if not isinstance(data, collections.Sequence):

pandas/core/series.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
144144
145145
Parameters
146146
----------
147-
data : array-like, dict, or scalar value
147+
data : array-like, Iterable, dict, or scalar value
148148
Contains data stored in Series
149149
150150
.. versionchanged :: 0.23.0
@@ -241,6 +241,7 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
241241
elif isinstance(data, (set, frozenset)):
242242
raise TypeError("{0!r} type is unordered"
243243
"".format(data.__class__.__name__))
244+
# If data is Iterable but not list-like, consume into list.
244245
elif (isinstance(data, collections.Iterable)
245246
and not isinstance(data, collections.Sized)):
246247
data = list(data)

0 commit comments

Comments
 (0)