@@ -219,3 +219,50 @@ def test_dt_unit(scalars_dfs, col_name):
219
219
pd_result = scalars_pandas_df [col_name ].dt .unit
220
220
221
221
assert bf_result == pd_result
222
+
223
+
224
+ @pytest .mark .parametrize (
225
+ ("column" , "date_format" ),
226
+ [
227
+ ("timestamp_col" , "%B %d, %Y, %r" ),
228
+ ("timestamp_col" , "%m-%d-%Y %H:%M" ),
229
+ ("datetime_col" , "%m-%d-%Y %H:%M" ),
230
+ ("datetime_col" , "%H:%M" ),
231
+ ],
232
+ )
233
+ @skip_legacy_pandas
234
+ def test_dt_strftime (scalars_df_index , scalars_pandas_df_index , column , date_format ):
235
+ bf_result = scalars_df_index [column ].dt .strftime (date_format ).to_pandas ()
236
+ pd_result = scalars_pandas_df_index [column ].dt .strftime (date_format )
237
+ pd .testing .assert_series_equal (bf_result , pd_result , check_dtype = False )
238
+ assert bf_result .dtype == "string[pyarrow]"
239
+
240
+
241
+ def test_dt_strftime_date ():
242
+ bf_series = bigframes .series .Series (
243
+ ["2014-08-15" , "2215-08-15" , "2016-02-29" ]
244
+ ).astype ("date32[day][pyarrow]" )
245
+
246
+ expected_result = pd .Series (["08/15/2014" , "08/15/2215" , "02/29/2016" ])
247
+ bf_result = bf_series .dt .strftime ("%m/%d/%Y" ).to_pandas ()
248
+
249
+ pd .testing .assert_series_equal (
250
+ bf_result , expected_result , check_index_type = False , check_dtype = False
251
+ )
252
+ assert bf_result .dtype == "string[pyarrow]"
253
+
254
+
255
+ def test_dt_strftime_time ():
256
+ bf_series = bigframes .series .Series (
257
+ [143542314 , 345234512341 , 75543252344 , 626546437654754 , 8543523452345234 ]
258
+ ).astype ("time64[us][pyarrow]" )
259
+
260
+ expected_result = pd .Series (
261
+ ["00:02:23" , "23:53:54" , "20:59:03" , "16:40:37" , "08:57:32" ]
262
+ )
263
+ bf_result = bf_series .dt .strftime ("%X" ).to_pandas ()
264
+
265
+ pd .testing .assert_series_equal (
266
+ bf_result , expected_result , check_index_type = False , check_dtype = False
267
+ )
268
+ assert bf_result .dtype == "string[pyarrow]"
0 commit comments