Skip to content

Commit 2ec4fec

Browse files
authored
Update test_constructors.py
1 parent 1856dea commit 2ec4fec

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/series/test_constructors.py

+17
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,23 @@ def test_constructor_set(self):
937937
values = frozenset(values)
938938
pytest.raises(TypeError, Series, values)
939939

940+
@pytest.mark.parametrize(
941+
"src",
942+
[pd.date_range('2016-01-01', periods=10, tz='US/Pacific'),
943+
pd.timedelta_range('1 day', periods=10),
944+
pd.period_range('2012Q1', periods=3, freq='Q'),
945+
pd.Index(list('abcdefghij')),
946+
pd.Int64Index(np.arange(10)),
947+
pd.RangeIndex(0, 10)])
948+
def test_fromIndex(self, src):
949+
# GH21907
950+
# When constructing a series from an index,
951+
# the series does not share data with that index
952+
expected = src.copy(deep=True)
953+
prod = Series(src)
954+
prod[::3] = NaT
955+
tm.assert_index_equal(src, expected)
956+
940957
def test_fromDict(self):
941958
data = {'a': 0, 'b': 1, 'c': 2, 'd': 3}
942959

0 commit comments

Comments
 (0)