@@ -178,6 +178,96 @@ def test_timestamp_add_dataframes(temporal_dfs):
178178 )
179179
180180
181+ @pytest .mark .parametrize (
182+ ("column" , "pd_dtype" ),
183+ [
184+ ("datetime_col" , "<M8[ns]" ),
185+ ("timestamp_col" , "datetime64[ns, UTC]" ),
186+ ],
187+ )
188+ def test_timestamp_sub__ts_series_minus_td_series (temporal_dfs , column , pd_dtype ):
189+ bf_df , pd_df = temporal_dfs
190+
191+ actual_result = (
192+ (bf_df [column ] - bf_df ["timedelta_col_1" ]).to_pandas ().astype (pd_dtype )
193+ )
194+
195+ expected_result = pd_df [column ] - pd_df ["timedelta_col_1" ]
196+ pandas .testing .assert_series_equal (
197+ actual_result , expected_result , check_index_type = False
198+ )
199+
200+
201+ @pytest .mark .parametrize (
202+ ("column" , "pd_dtype" ),
203+ [
204+ ("datetime_col" , "<M8[ns]" ),
205+ ("timestamp_col" , "datetime64[ns, UTC]" ),
206+ ],
207+ )
208+ def test_timestamp_sub__ts_series_minus_td_literal (temporal_dfs , column , pd_dtype ):
209+ bf_df , pd_df = temporal_dfs
210+ literal = pd .Timedelta (1 , "h" )
211+
212+ actual_result = (bf_df [column ] - literal ).to_pandas ().astype (pd_dtype )
213+
214+ expected_result = pd_df [column ] - literal
215+ pandas .testing .assert_series_equal (
216+ actual_result , expected_result , check_index_type = False
217+ )
218+
219+
220+ def test_timestamp_sub__ts_literal_minus_td_series (temporal_dfs ):
221+ bf_df , pd_df = temporal_dfs
222+ literal = pd .Timestamp ("2025-01-01 01:00:00" )
223+
224+ actual_result = (literal - bf_df ["timedelta_col_1" ]).to_pandas ().astype ("<M8[ns]" )
225+
226+ expected_result = literal - pd_df ["timedelta_col_1" ]
227+ pandas .testing .assert_series_equal (
228+ actual_result , expected_result , check_index_type = False
229+ )
230+
231+
232+ @pytest .mark .parametrize (
233+ ("column" , "pd_dtype" ),
234+ [
235+ ("datetime_col" , "<M8[ns]" ),
236+ ("timestamp_col" , "datetime64[ns, UTC]" ),
237+ ],
238+ )
239+ def test_timestamp_sub_with_numpy_op (temporal_dfs , column , pd_dtype ):
240+ bf_df , pd_df = temporal_dfs
241+
242+ actual_result = (
243+ np .subtract (bf_df [column ], bf_df ["timedelta_col_1" ])
244+ .to_pandas ()
245+ .astype (pd_dtype )
246+ )
247+
248+ expected_result = np .subtract (pd_df [column ], pd_df ["timedelta_col_1" ])
249+ pandas .testing .assert_series_equal (
250+ actual_result , expected_result , check_index_type = False
251+ )
252+
253+
254+ def test_timestamp_sub_dataframes (temporal_dfs ):
255+ columns = ["datetime_col" , "timestamp_col" ]
256+ timedelta = pd .Timedelta (1 , unit = "s" )
257+ bf_df , pd_df = temporal_dfs
258+
259+ actual_result = (bf_df [columns ] - timedelta ).to_pandas ()
260+ actual_result ["datetime_col" ] = actual_result ["datetime_col" ].astype ("<M8[ns]" )
261+ actual_result ["timestamp_col" ] = actual_result ["timestamp_col" ].astype (
262+ "datetime64[ns, UTC]"
263+ )
264+
265+ expected_result = pd_df [columns ] - timedelta
266+ pandas .testing .assert_frame_equal (
267+ actual_result , expected_result , check_index_type = False
268+ )
269+
270+
181271@pytest .mark .parametrize (
182272 "compare_func" ,
183273 [
0 commit comments