Skip to content

Commit bff99a8

Browse files
committed
simpler test
1 parent 9edac8c commit bff99a8

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

pandas/tests/arrays/test_timedeltas.py

+4-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from datetime import (
2-
datetime,
3-
timedelta,
4-
)
1+
from datetime import timedelta
52

63
import numpy as np
74
import pytest
@@ -70,28 +67,11 @@ def test_total_seconds(self, unit, tda):
7067
expected = tda_nano.total_seconds()
7168
tm.assert_numpy_array_equal(result, expected)
7269

73-
def test_series_total_seconds(self):
74-
# GH34290
75-
expected = float(15)
76-
out = pd.Series(
77-
[pd.Timestamp("2022-03-16 08:32:26"), pd.Timestamp("2022-03-16 08:32:41")]
78-
)
79-
80-
result = (out - out.iloc[0]).dt.total_seconds()[1]
81-
assert result == expected
82-
83-
def test_dateframe_total_seconds(self):
70+
def test_timedelta_array_total_seconds(self):
8471
# GH34290
85-
expected = float(120)
86-
data = {"start": datetime(2020, 1, 1, 12), "end": datetime(2020, 1, 1, 12, 2)}
87-
df = pd.DataFrame(data, index=[0])
88-
89-
# try to parse to pd.to_datetime
90-
df["end"] = pd.to_datetime(df["end"])
91-
df["start"] = pd.to_datetime(df["start"])
92-
93-
result = (df["end"] - df["start"]).dt.total_seconds().values[0]
72+
expected = pd.Timedelta("2 min").total_seconds()
9473

74+
result = pd.array([pd.Timedelta("2 min")]).total_seconds()[0]
9575
assert result == expected
9676

9777
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)