Skip to content

Commit e26f9bf

Browse files
committed
BUG: construction of Series with integers on windows not
defaulting to int64 closes #13646
1 parent 0a70b5f commit e26f9bf

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

doc/source/whatsnew/v0.19.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ Bug Fixes
534534
- Bug when passing a not-default-indexed ``Series`` as ``xerr`` or ``yerr`` in ``.plot()`` (:issue:`11858`)
535535
- Bug in matplotlib ``AutoDataFormatter``; this restores the second scaled formatting and re-adds micro-second scaled formatting (:issue:`13131`)
536536
- Bug in selection from a ``HDFStore`` with a fixed format and ``start`` and/or ``stop`` specified will now return the selected range (:issue:`8287`)
537-
537+
- Bug in ``Series`` construction from a tuple of integers on windows not returning default dtype (int64) (:issue:`13646`)
538538

539539
- Bug in ``.groupby(..).resample(..)`` when the same object is called multiple times (:issue:`13174`)
540540
- Bug in ``.to_records()`` when index name is a unicode string (:issue:`13172`)

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2820,7 +2820,7 @@ def _try_cast(arr, take_fast_path):
28202820
subarr = data.copy()
28212821
return subarr
28222822

2823-
elif isinstance(data, list) and len(data) > 0:
2823+
elif isinstance(data, (list, tuple)) and len(data) > 0:
28242824
if dtype is not None:
28252825
try:
28262826
subarr = _try_cast(data, False)

pandas/tests/frame/test_operators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ def test_alignment_non_pandas(self):
11961196

11971197
align = pd.core.ops._align_method_FRAME
11981198

1199-
for val in [[1, 2, 3], (1, 2, 3), np.array([1, 2, 3])]:
1199+
for val in [[1, 2, 3], (1, 2, 3), np.array([1, 2, 3], dtype=np.intp)]:
12001200

12011201
tm.assert_series_equal(align(df, val, 'index'),
12021202
Series([1, 2, 3], index=df.index))

pandas/tests/series/test_constructors.py

+11
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ def test_constructor_iterator(self):
109109
result = Series(range(10), dtype='int64')
110110
assert_series_equal(result, expected)
111111

112+
def test_constructor_list_like(self):
113+
114+
# make sure that we are coercing different
115+
# list-likes to standard dtypes and not
116+
# platform specific
117+
expected = Series([1, 2, 3], dtype='int64')
118+
for obj in [[1, 2, 3], (1, 2, 3),
119+
np.array([1, 2, 3], dtype='int64')]:
120+
result = Series(obj, index=[0, 1, 2])
121+
assert_series_equal(result, expected)
122+
112123
def test_constructor_generator(self):
113124
gen = (i for i in range(10))
114125

pandas/types/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _possibly_convert_platform(values):
3333
""" try to do platform conversion, allow ndarray or list here """
3434

3535
if isinstance(values, (list, tuple)):
36-
values = lib.list_to_object_array(values)
36+
values = lib.list_to_object_array(list(values))
3737
if getattr(values, 'dtype', None) == np.object_:
3838
if hasattr(values, '_values'):
3939
values = values._values

0 commit comments

Comments
 (0)