@@ -252,11 +252,11 @@ def truediv(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
252
252
253
253
def truediv (left : PySparkColumn , right : Any ) -> PySparkColumn :
254
254
return F .when (
255
- right_col == 0 ,
256
- F .when (left_col < 0 , F .lit (float ("-inf" )))
257
- .when (left_col > 0 , F .lit (float ("inf" )))
255
+ right == 0 ,
256
+ F .when (left < 0 , F .lit (float ("-inf" )))
257
+ .when (left > 0 , F .lit (float ("inf" )))
258
258
.otherwise (F .lit (np .nan )),
259
- ).otherwise (left_col / right_col )
259
+ ).otherwise (left / right )
260
260
261
261
return numpy_column_op (truediv )(left , right )
262
262
@@ -336,15 +336,13 @@ def truediv(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex:
336
336
if not is_valid_operand_for_numeric_arithmetic (right ):
337
337
raise TypeError ("True division can not be applied to given types." )
338
338
339
- def truediv (left_col : PySparkColumn , right_val : Any ) -> PySparkColumn :
339
+ def truediv (left : PySparkColumn , right : Any ) -> PySparkColumn :
340
340
return F .when (
341
- F .lit (right_val != 0 ) | F .lit (right_val ).isNull (),
342
- left_col / right_val ,
343
- ).otherwise (
344
- F .when (
345
- (left_col == float ("inf" )) | (left_col == float ("-inf" )), left_col
346
- ).otherwise (float ("inf" ) / left_col )
347
- )
341
+ right == 0 ,
342
+ F .when (left < 0 , F .lit (float ("-inf" )))
343
+ .when (left > 0 , F .lit (float ("inf" )))
344
+ .otherwise (F .lit (np .nan )),
345
+ ).otherwise (left / right )
348
346
349
347
right = transform_boolean_operand_to_numeric (right , spark_type = left .spark .data_type )
350
348
return numpy_column_op (truediv )(left , right )
0 commit comments