Skip to content

Commit c940c86

Browse files
update indexes / indexing tests
1 parent fd6c6df commit c940c86

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

pandas/tests/indexes/datetimes/test_constructors.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def test_construction_dti_with_mixed_timezones(self):
524524
Timestamp("2011-01-01 10:00", tz="Asia/Tokyo"),
525525
Timestamp("2011-01-02 10:00", tz="US/Eastern"),
526526
],
527-
dtype="M8[s, US/Eastern]",
527+
dtype="M8[us, US/Eastern]",
528528
name="idx",
529529
)
530530
tm.assert_index_equal(dti, expected)
@@ -602,7 +602,7 @@ def test_constructor_coverage(self):
602602
expected = DatetimeIndex(strings.astype("O"))
603603
tm.assert_index_equal(result, expected)
604604

605-
from_ints = DatetimeIndex(expected.as_unit("ns").asi8).as_unit("s")
605+
from_ints = DatetimeIndex(expected.as_unit("ns").asi8).as_unit("us")
606606
tm.assert_index_equal(from_ints, expected)
607607

608608
# string with NaT
@@ -611,7 +611,7 @@ def test_constructor_coverage(self):
611611
expected = DatetimeIndex(strings.astype("O"))
612612
tm.assert_index_equal(result, expected)
613613

614-
from_ints = DatetimeIndex(expected.as_unit("ns").asi8).as_unit("s")
614+
from_ints = DatetimeIndex(expected.as_unit("ns").asi8).as_unit("us")
615615
tm.assert_index_equal(from_ints, expected)
616616

617617
# non-conforming
@@ -840,8 +840,8 @@ def test_construction_with_tz_and_tz_aware_dti(self):
840840

841841
def test_construction_with_nat_and_tzlocal(self):
842842
tz = dateutil.tz.tzlocal()
843-
result = DatetimeIndex(["2018", "NaT"], tz=tz).as_unit("ns")
844-
expected = DatetimeIndex([Timestamp("2018", tz=tz), pd.NaT]).as_unit("ns")
843+
result = DatetimeIndex(["2018", "NaT"], tz=tz)
844+
expected = DatetimeIndex([Timestamp("2018", tz=tz), pd.NaT])
845845
tm.assert_index_equal(result, expected)
846846

847847
def test_constructor_with_ambiguous_keyword_arg(self):
@@ -940,11 +940,11 @@ def test_dti_tz_constructors(self, tzstr):
940940

941941
idx1 = to_datetime(arr).tz_localize(tzstr)
942942
idx2 = date_range(
943-
start="2005-11-10 08:00:00", freq="h", periods=2, tz=tzstr, unit="s"
943+
start="2005-11-10 08:00:00", freq="h", periods=2, tz=tzstr, unit="us"
944944
)
945945
idx2 = idx2._with_freq(None) # the others all have freq=None
946-
idx3 = DatetimeIndex(arr, tz=tzstr).as_unit("s")
947-
idx4 = DatetimeIndex(np.array(arr), tz=tzstr).as_unit("s")
946+
idx3 = DatetimeIndex(arr, tz=tzstr)
947+
idx4 = DatetimeIndex(np.array(arr), tz=tzstr)
948948

949949
tm.assert_index_equal(idx1, idx2)
950950
tm.assert_index_equal(idx1, idx3)
@@ -1211,9 +1211,9 @@ def test_dti_constructor_object_dtype_dayfirst_yearfirst_with_tz(self):
12111211
yfirst = Timestamp(2005, 10, 16, tz="US/Pacific")
12121212

12131213
result1 = DatetimeIndex([val], tz="US/Pacific", dayfirst=True)
1214-
expected1 = DatetimeIndex([dfirst]).as_unit("s")
1214+
expected1 = DatetimeIndex([dfirst])
12151215
tm.assert_index_equal(result1, expected1)
12161216

12171217
result2 = DatetimeIndex([val], tz="US/Pacific", yearfirst=True)
1218-
expected2 = DatetimeIndex([yfirst]).as_unit("s")
1218+
expected2 = DatetimeIndex([yfirst])
12191219
tm.assert_index_equal(result2, expected2)

pandas/tests/indexing/test_coercion.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def test_fillna_complex128(self, index_or_series, fill_val, fill_dtype):
596596
@pytest.mark.parametrize(
597597
"fill_val,fill_dtype",
598598
[
599-
(pd.Timestamp("2012-01-01"), "datetime64[s]"),
599+
(pd.Timestamp("2012-01-01"), "datetime64[us]"),
600600
(pd.Timestamp("2012-01-01", tz="US/Eastern"), object),
601601
(1, object),
602602
("x", object),
@@ -613,7 +613,7 @@ def test_fillna_datetime(self, index_or_series, fill_val, fill_dtype):
613613
pd.Timestamp("2011-01-04"),
614614
]
615615
)
616-
assert obj.dtype == "datetime64[s]"
616+
assert obj.dtype == "datetime64[us]"
617617

618618
exp = klass(
619619
[
@@ -628,10 +628,10 @@ def test_fillna_datetime(self, index_or_series, fill_val, fill_dtype):
628628
@pytest.mark.parametrize(
629629
"fill_val,fill_dtype",
630630
[
631-
(pd.Timestamp("2012-01-01", tz="US/Eastern"), "datetime64[s, US/Eastern]"),
631+
(pd.Timestamp("2012-01-01", tz="US/Eastern"), "datetime64[us, US/Eastern]"),
632632
(pd.Timestamp("2012-01-01"), object),
633633
# pre-2.0 with a mismatched tz we would get object result
634-
(pd.Timestamp("2012-01-01", tz="Asia/Tokyo"), "datetime64[s, US/Eastern]"),
634+
(pd.Timestamp("2012-01-01", tz="Asia/Tokyo"), "datetime64[us, US/Eastern]"),
635635
(1, object),
636636
("x", object),
637637
],
@@ -648,7 +648,7 @@ def test_fillna_datetime64tz(self, index_or_series, fill_val, fill_dtype):
648648
pd.Timestamp("2011-01-04", tz=tz),
649649
]
650650
)
651-
assert obj.dtype == "datetime64[s, US/Eastern]"
651+
assert obj.dtype == "datetime64[us, US/Eastern]"
652652

653653
if getattr(fill_val, "tz", None) is None:
654654
fv = fill_val

pandas/tests/indexing/test_loc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def test_loc_modify_datetime(self):
701701
{"date": [1485264372711, 1485265925110, 1540215845888, 1540282121025]}
702702
)
703703

704-
df["date_dt"] = to_datetime(df["date"], unit="ms", cache=True).dt.as_unit("ms")
704+
df["date_dt"] = to_datetime(df["date"], unit="ms", cache=True).dt.as_unit("us")
705705

706706
df.loc[:, "date_dt_cp"] = df.loc[:, "date_dt"]
707707
df.loc[[2, 3], "date_dt_cp"] = df.loc[[2, 3], "date_dt"]

pandas/tests/indexing/test_partial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ def test_partial_set_invalid(self):
574574
],
575575
),
576576
(
577-
date_range(start="2000", periods=20, freq="D", unit="s"),
577+
date_range(start="2000", periods=20, freq="D", unit="us"),
578578
["2000-01-04", "2000-01-08", "2000-01-12"],
579579
[
580580
Timestamp("2000-01-04"),

0 commit comments

Comments
 (0)