Skip to content

Commit 9bcda57

Browse files
committed
Update test_constructors.py
1 parent d359d3b commit 9bcda57

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/series/test_constructors.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,23 @@ def test_constructor_set(self):
970970
values = frozenset(values)
971971
pytest.raises(TypeError, Series, values)
972972

973+
@pytest.mark.parametrize(
974+
"src",
975+
[pd.date_range('2016-01-01', periods=10, tz='US/Pacific'),
976+
pd.timedelta_range('1 day', periods=10),
977+
pd.period_range('2012Q1', periods=3, freq='Q'),
978+
pd.Index(list('abcdefghij')),
979+
pd.Int64Index(np.arange(10)),
980+
pd.RangeIndex(0, 10)])
981+
def test_fromIndex(self, src):
982+
# GH21907
983+
# When constructing a series from an index,
984+
# the series does not share data with that index
985+
expected = src.copy(deep=True)
986+
prod = Series(src)
987+
prod[::3] = NaT
988+
tm.assert_index_equal(src, expected)
989+
973990
# https://github.com/pandas-dev/pandas/issues/22698
974991
@pytest.mark.filterwarnings("ignore:elementwise comparison:FutureWarning")
975992
def test_fromDict(self):

0 commit comments

Comments
 (0)