@@ -271,13 +271,14 @@ def floordiv(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
271
271
_sanitize_list_like (right )
272
272
if not is_valid_operand_for_numeric_arithmetic (right ):
273
273
raise TypeError ("Floor division can not be applied to given types." )
274
+ spark_session = left ._internal .spark_frame .sparkSession
274
275
275
276
def floordiv (left : PySparkColumn , right : Any ) -> PySparkColumn :
276
277
return F .when (F .lit (right is np .nan ), np .nan ).otherwise (
277
278
F .when (
278
279
F .lit (right != 0 ) | F .lit (right ).isNull (),
279
280
F .floor (left .__div__ (right )),
280
- ).otherwise (F .lit (np .inf ). __div__ ( left ))
281
+ ).otherwise (F .try_divide ( F . lit (np .inf ), left ))
281
282
)
282
283
283
284
right = transform_boolean_operand_to_numeric (right , spark_type = left .spark .data_type )
@@ -369,6 +370,7 @@ def floordiv(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
369
370
_sanitize_list_like (right )
370
371
if not is_valid_operand_for_numeric_arithmetic (right ):
371
372
raise TypeError ("Floor division can not be applied to given types." )
373
+ spark_session = left ._internal .spark_frame .sparkSession
372
374
373
375
def floordiv (left : PySparkColumn , right : Any ) -> PySparkColumn :
374
376
return F .when (F .lit (right is np .nan ), np .nan ).otherwise (
@@ -377,7 +379,7 @@ def floordiv(left: PySparkColumn, right: Any) -> PySparkColumn:
377
379
F .floor (left .__div__ (right )),
378
380
).otherwise (
379
381
F .when (F .lit (left == np .inf ) | F .lit (left == - np .inf ), left ).otherwise (
380
- F .lit (np .inf ). __div__ ( left )
382
+ F .try_divide ( F . lit (np .inf ), left )
381
383
)
382
384
)
383
385
)
0 commit comments