19
19
Timedelta ,
20
20
TimedeltaIndex ,
21
21
array ,
22
+ date_range ,
22
23
)
23
24
import pandas ._testing as tm
24
25
from pandas .core import ops
@@ -733,7 +734,7 @@ def test_mul_datelike_raises(self, numeric_idx):
733
734
idx = numeric_idx
734
735
msg = "cannot perform __rmul__ with this index type"
735
736
with pytest .raises (TypeError , match = msg ):
736
- idx * pd . date_range ("20130101" , periods = 5 )
737
+ idx * date_range ("20130101" , periods = 5 )
737
738
738
739
def test_mul_size_mismatch_raises (self , numeric_idx ):
739
740
idx = numeric_idx
@@ -820,7 +821,11 @@ def test_ops_np_scalar(self, other):
820
821
# TODO: This came from series.test.test_operators, needs cleanup
821
822
def test_operators_frame (self ):
822
823
# rpow does not work with DataFrame
823
- ts = tm .makeTimeSeries ()
824
+ ts = Series (
825
+ np .arange (10 , dtype = np .float64 ),
826
+ index = date_range ("2020-01-01" , periods = 10 ),
827
+ name = "ts" ,
828
+ )
824
829
ts .name = "ts"
825
830
826
831
df = pd .DataFrame ({"A" : ts })
@@ -926,8 +931,11 @@ def test_series_frame_radd_bug(self, fixed_now_ts):
926
931
expected = pd .DataFrame ({"vals" : vals .map (lambda x : "foo_" + x )})
927
932
tm .assert_frame_equal (result , expected )
928
933
929
- ts = tm .makeTimeSeries ()
930
- ts .name = "ts"
934
+ ts = Series (
935
+ np .arange (10 , dtype = np .float64 ),
936
+ index = date_range ("2020-01-01" , periods = 10 ),
937
+ name = "ts" ,
938
+ )
931
939
932
940
# really raise this time
933
941
fix_now = fixed_now_ts .to_pydatetime ()
@@ -955,8 +963,8 @@ def test_datetime64_with_index(self):
955
963
# GH#4629
956
964
# arithmetic datetime64 ops with an index
957
965
ser = Series (
958
- pd . date_range ("20130101" , periods = 5 ),
959
- index = pd . date_range ("20130101" , periods = 5 ),
966
+ date_range ("20130101" , periods = 5 ),
967
+ index = date_range ("20130101" , periods = 5 ),
960
968
)
961
969
expected = ser - ser .index .to_series ()
962
970
result = ser - ser .index
@@ -969,7 +977,7 @@ def test_datetime64_with_index(self):
969
977
970
978
df = pd .DataFrame (
971
979
np .random .default_rng (2 ).standard_normal ((5 , 2 )),
972
- index = pd . date_range ("20130101" , periods = 5 ),
980
+ index = date_range ("20130101" , periods = 5 ),
973
981
)
974
982
df ["date" ] = pd .Timestamp ("20130102" )
975
983
df ["expected" ] = df ["date" ] - df .index .to_series ()
@@ -1031,7 +1039,11 @@ def test_frame_operators_empty_like(self, dtype):
1031
1039
)
1032
1040
def test_series_operators_arithmetic (self , all_arithmetic_functions , func ):
1033
1041
op = all_arithmetic_functions
1034
- series = tm .makeTimeSeries ().rename ("ts" )
1042
+ series = Series (
1043
+ np .arange (10 , dtype = np .float64 ),
1044
+ index = date_range ("2020-01-01" , periods = 10 ),
1045
+ name = "ts" ,
1046
+ )
1035
1047
other = func (series )
1036
1048
compare_op (series , other , op )
1037
1049
@@ -1040,7 +1052,11 @@ def test_series_operators_arithmetic(self, all_arithmetic_functions, func):
1040
1052
)
1041
1053
def test_series_operators_compare (self , comparison_op , func ):
1042
1054
op = comparison_op
1043
- series = tm .makeTimeSeries ().rename ("ts" )
1055
+ series = Series (
1056
+ np .arange (10 , dtype = np .float64 ),
1057
+ index = date_range ("2020-01-01" , periods = 10 ),
1058
+ name = "ts" ,
1059
+ )
1044
1060
other = func (series )
1045
1061
compare_op (series , other , op )
1046
1062
@@ -1050,7 +1066,11 @@ def test_series_operators_compare(self, comparison_op, func):
1050
1066
ids = ["multiply" , "slice" , "constant" ],
1051
1067
)
1052
1068
def test_divmod (self , func ):
1053
- series = tm .makeTimeSeries ().rename ("ts" )
1069
+ series = Series (
1070
+ np .arange (10 , dtype = np .float64 ),
1071
+ index = date_range ("2020-01-01" , periods = 10 ),
1072
+ name = "ts" ,
1073
+ )
1054
1074
other = func (series )
1055
1075
results = divmod (series , other )
1056
1076
if isinstance (other , abc .Iterable ) and len (series ) != len (other ):
@@ -1081,7 +1101,11 @@ def test_series_divmod_zero(self):
1081
1101
# -1/0 == -np.inf
1082
1102
# 1/-0.0 == -np.inf
1083
1103
# -1/-0.0 == np.inf
1084
- tser = tm .makeTimeSeries ().rename ("ts" )
1104
+ tser = Series (
1105
+ np .arange (1 , 11 , dtype = np .float64 ),
1106
+ index = date_range ("2020-01-01" , periods = 10 ),
1107
+ name = "ts" ,
1108
+ )
1085
1109
other = tser * 0
1086
1110
1087
1111
result = divmod (tser , other )
0 commit comments