@@ -25365,13 +25365,27 @@ def isnotnull(col: "ColumnOrName") -> Column:
25365
25365
25366
25366
Parameters
25367
25367
----------
25368
- col : :class:`~pyspark.sql.Column` or str
25368
+ col : :class:`~pyspark.sql.Column` or column name
25369
25369
25370
25370
Examples
25371
25371
--------
25372
+ >>> from pyspark.sql import functions as sf
25372
25373
>>> df = spark.createDataFrame([(None,), (1,)], ["e"])
25373
- >>> df.select(isnotnull(df.e).alias('r')).collect()
25374
- [Row(r=False), Row(r=True)]
25374
+ >>> df.select('*', sf.isnotnull(df.e)).show()
25375
+ +----+---------------+
25376
+ | e|(e IS NOT NULL)|
25377
+ +----+---------------+
25378
+ |NULL| false|
25379
+ | 1| true|
25380
+ +----+---------------+
25381
+
25382
+ >>> df.select('*', sf.isnotnull('e')).show()
25383
+ +----+---------------+
25384
+ | e|(e IS NOT NULL)|
25385
+ +----+---------------+
25386
+ |NULL| false|
25387
+ | 1| true|
25388
+ +----+---------------+
25375
25389
"""
25376
25390
return _invoke_function_over_columns("isnotnull", col)
25377
25391
@@ -25386,14 +25400,28 @@ def equal_null(col1: "ColumnOrName", col2: "ColumnOrName") -> Column:
25386
25400
25387
25401
Parameters
25388
25402
----------
25389
- col1 : :class:`~pyspark.sql.Column` or str
25390
- col2 : :class:`~pyspark.sql.Column` or str
25403
+ col1 : :class:`~pyspark.sql.Column` or column name
25404
+ col2 : :class:`~pyspark.sql.Column` or column name
25391
25405
25392
25406
Examples
25393
25407
--------
25408
+ >>> from pyspark.sql import functions as sf
25394
25409
>>> df = spark.createDataFrame([(None, None,), (1, 9,)], ["a", "b"])
25395
- >>> df.select(equal_null(df.a, df.b).alias('r')).collect()
25396
- [Row(r=True), Row(r=False)]
25410
+ >>> df.select('*', sf.equal_null(df.a, df.b)).show()
25411
+ +----+----+----------------+
25412
+ | a| b|equal_null(a, b)|
25413
+ +----+----+----------------+
25414
+ |NULL|NULL| true|
25415
+ | 1| 9| false|
25416
+ +----+----+----------------+
25417
+
25418
+ >>> df.select('*', sf.equal_null('a', 'b')).show()
25419
+ +----+----+----------------+
25420
+ | a| b|equal_null(a, b)|
25421
+ +----+----+----------------+
25422
+ |NULL|NULL| true|
25423
+ | 1| 9| false|
25424
+ +----+----+----------------+
25397
25425
"""
25398
25426
return _invoke_function_over_columns("equal_null", col1, col2)
25399
25427
@@ -25407,14 +25435,28 @@ def nullif(col1: "ColumnOrName", col2: "ColumnOrName") -> Column:
25407
25435
25408
25436
Parameters
25409
25437
----------
25410
- col1 : :class:`~pyspark.sql.Column` or str
25411
- col2 : :class:`~pyspark.sql.Column` or str
25438
+ col1 : :class:`~pyspark.sql.Column` or column name
25439
+ col2 : :class:`~pyspark.sql.Column` or column name
25412
25440
25413
25441
Examples
25414
25442
--------
25443
+ >>> import pyspark.sql.functions as sf
25415
25444
>>> df = spark.createDataFrame([(None, None,), (1, 9,)], ["a", "b"])
25416
- >>> df.select(nullif(df.a, df.b).alias('r')).collect()
25417
- [Row(r=None), Row(r=1)]
25445
+ >>> df.select('*', sf.nullif(df.a, df.b)).show()
25446
+ +----+----+------------+
25447
+ | a| b|nullif(a, b)|
25448
+ +----+----+------------+
25449
+ |NULL|NULL| NULL|
25450
+ | 1| 9| 1|
25451
+ +----+----+------------+
25452
+
25453
+ >>> df.select('*', sf.nullif('a', 'b')).show()
25454
+ +----+----+------------+
25455
+ | a| b|nullif(a, b)|
25456
+ +----+----+------------+
25457
+ |NULL|NULL| NULL|
25458
+ | 1| 9| 1|
25459
+ +----+----+------------+
25418
25460
"""
25419
25461
return _invoke_function_over_columns("nullif", col1, col2)
25420
25462
@@ -25428,18 +25470,27 @@ def nullifzero(col: "ColumnOrName") -> Column:
25428
25470
25429
25471
Parameters
25430
25472
----------
25431
- col : :class:`~pyspark.sql.Column` or str
25473
+ col : :class:`~pyspark.sql.Column` or column name
25432
25474
25433
25475
Examples
25434
25476
--------
25477
+ >>> import pyspark.sql.functions as sf
25435
25478
>>> df = spark.createDataFrame([(0,), (1,)], ["a"])
25436
- >>> df.select(nullifzero(df.a).alias("result")).show()
25437
- +------+
25438
- |result|
25439
- +------+
25440
- | NULL|
25441
- | 1|
25442
- +------+
25479
+ >>> df.select('*', sf.nullifzero(df.a)).show()
25480
+ +---+-------------+
25481
+ | a|nullifzero(a)|
25482
+ +---+-------------+
25483
+ | 0| NULL|
25484
+ | 1| 1|
25485
+ +---+-------------+
25486
+
25487
+ >>> df.select('*', sf.nullifzero('a')).show()
25488
+ +---+-------------+
25489
+ | a|nullifzero(a)|
25490
+ +---+-------------+
25491
+ | 0| NULL|
25492
+ | 1| 1|
25493
+ +---+-------------+
25443
25494
"""
25444
25495
return _invoke_function_over_columns("nullifzero", col)
25445
25496
@@ -25453,14 +25504,28 @@ def nvl(col1: "ColumnOrName", col2: "ColumnOrName") -> Column:
25453
25504
25454
25505
Parameters
25455
25506
----------
25456
- col1 : :class:`~pyspark.sql.Column` or str
25457
- col2 : :class:`~pyspark.sql.Column` or str
25507
+ col1 : :class:`~pyspark.sql.Column` or column name
25508
+ col2 : :class:`~pyspark.sql.Column` or column name
25458
25509
25459
25510
Examples
25460
25511
--------
25512
+ >>> import pyspark.sql.functions as sf
25461
25513
>>> df = spark.createDataFrame([(None, 8,), (1, 9,)], ["a", "b"])
25462
- >>> df.select(nvl(df.a, df.b).alias('r')).collect()
25463
- [Row(r=8), Row(r=1)]
25514
+ >>> df.select('*', sf.nvl(df.a, df.b)).show()
25515
+ +----+---+---------+
25516
+ | a| b|nvl(a, b)|
25517
+ +----+---+---------+
25518
+ |NULL| 8| 8|
25519
+ | 1| 9| 1|
25520
+ +----+---+---------+
25521
+
25522
+ >>> df.select('*', sf.nvl('a', 'b')).show()
25523
+ +----+---+---------+
25524
+ | a| b|nvl(a, b)|
25525
+ +----+---+---------+
25526
+ |NULL| 8| 8|
25527
+ | 1| 9| 1|
25528
+ +----+---+---------+
25464
25529
"""
25465
25530
return _invoke_function_over_columns("nvl", col1, col2)
25466
25531
@@ -25474,15 +25539,29 @@ def nvl2(col1: "ColumnOrName", col2: "ColumnOrName", col3: "ColumnOrName") -> Co
25474
25539
25475
25540
Parameters
25476
25541
----------
25477
- col1 : :class:`~pyspark.sql.Column` or str
25478
- col2 : :class:`~pyspark.sql.Column` or str
25479
- col3 : :class:`~pyspark.sql.Column` or str
25542
+ col1 : :class:`~pyspark.sql.Column` or column name
25543
+ col2 : :class:`~pyspark.sql.Column` or column name
25544
+ col3 : :class:`~pyspark.sql.Column` or column name
25480
25545
25481
25546
Examples
25482
25547
--------
25548
+ >>> import pyspark.sql.functions as sf
25483
25549
>>> df = spark.createDataFrame([(None, 8, 6,), (1, 9, 9,)], ["a", "b", "c"])
25484
- >>> df.select(nvl2(df.a, df.b, df.c).alias('r')).collect()
25485
- [Row(r=6), Row(r=9)]
25550
+ >>> df.select('*', sf.nvl2(df.a, df.b, df.c)).show()
25551
+ +----+---+---+-------------+
25552
+ | a| b| c|nvl2(a, b, c)|
25553
+ +----+---+---+-------------+
25554
+ |NULL| 8| 6| 6|
25555
+ | 1| 9| 9| 9|
25556
+ +----+---+---+-------------+
25557
+
25558
+ >>> df.select('*', sf.nvl2('a', 'b', 'c')).show()
25559
+ +----+---+---+-------------+
25560
+ | a| b| c|nvl2(a, b, c)|
25561
+ +----+---+---+-------------+
25562
+ |NULL| 8| 6| 6|
25563
+ | 1| 9| 9| 9|
25564
+ +----+---+---+-------------+
25486
25565
"""
25487
25566
return _invoke_function_over_columns("nvl2", col1, col2, col3)
25488
25567
@@ -25496,18 +25575,27 @@ def zeroifnull(col: "ColumnOrName") -> Column:
25496
25575
25497
25576
Parameters
25498
25577
----------
25499
- col : :class:`~pyspark.sql.Column` or str
25578
+ col : :class:`~pyspark.sql.Column` or column name
25500
25579
25501
25580
Examples
25502
25581
--------
25582
+ >>> import pyspark.sql.functions as sf
25503
25583
>>> df = spark.createDataFrame([(None,), (1,)], ["a"])
25504
- >>> df.select(zeroifnull(df.a).alias("result")).show()
25505
- +------+
25506
- |result|
25507
- +------+
25508
- | 0|
25509
- | 1|
25510
- +------+
25584
+ >>> df.select('*', sf.zeroifnull(df.a)).show()
25585
+ +----+-------------+
25586
+ | a|zeroifnull(a)|
25587
+ +----+-------------+
25588
+ |NULL| 0|
25589
+ | 1| 1|
25590
+ +----+-------------+
25591
+
25592
+ >>> df.select('*', sf.zeroifnull('a')).show()
25593
+ +----+-------------+
25594
+ | a|zeroifnull(a)|
25595
+ +----+-------------+
25596
+ |NULL| 0|
25597
+ | 1| 1|
25598
+ +----+-------------+
25511
25599
"""
25512
25600
return _invoke_function_over_columns("zeroifnull", col)
25513
25601
0 commit comments