@@ -495,16 +495,28 @@ def abs(arg: Expr) -> Expr:
495495def acos (arg : Expr ) -> Expr :
496496 """Returns the arc cosine or inverse cosine of a number.
497497
498- Returns:
499- --------
500- Expr
501- A new expression representing the arc cosine of the input expression.
498+ Examples:
499+ ---------
500+ >>> ctx = dfn.SessionContext()
501+ >>> df = ctx.from_pydict({"a": [1.0]})
502+ >>> result = df.select(dfn.functions.acos(dfn.col("a")).alias("acos"))
503+ >>> result.collect_column("acos")[0].as_py()
504+ 0.0
502505 """
503506 return Expr (f .acos (arg .expr ))
504507
505508
506509def acosh (arg : Expr ) -> Expr :
507- """Returns inverse hyperbolic cosine."""
510+ """Returns inverse hyperbolic cosine.
511+
512+ Examples:
513+ ---------
514+ >>> ctx = dfn.SessionContext()
515+ >>> df = ctx.from_pydict({"a": [1.0]})
516+ >>> result = df.select(dfn.functions.acosh(dfn.col("a")).alias("acosh"))
517+ >>> result.collect_column("acosh")[0].as_py()
518+ 0.0
519+ """
508520 return Expr (f .acosh (arg .expr ))
509521
510522
@@ -514,27 +526,73 @@ def ascii(arg: Expr) -> Expr:
514526
515527
516528def asin (arg : Expr ) -> Expr :
517- """Returns the arc sine or inverse sine of a number."""
529+ """Returns the arc sine or inverse sine of a number.
530+
531+ Examples:
532+ ---------
533+ >>> ctx = dfn.SessionContext()
534+ >>> df = ctx.from_pydict({"a": [0.0]})
535+ >>> result = df.select(dfn.functions.asin(dfn.col("a")).alias("asin"))
536+ >>> result.collect_column("asin")[0].as_py()
537+ 0.0
538+ """
518539 return Expr (f .asin (arg .expr ))
519540
520541
521542def asinh (arg : Expr ) -> Expr :
522- """Returns inverse hyperbolic sine."""
543+ """Returns inverse hyperbolic sine.
544+
545+ Examples:
546+ ---------
547+ >>> ctx = dfn.SessionContext()
548+ >>> df = ctx.from_pydict({"a": [0.0]})
549+ >>> result = df.select(dfn.functions.asinh(dfn.col("a")).alias("asinh"))
550+ >>> result.collect_column("asinh")[0].as_py()
551+ 0.0
552+ """
523553 return Expr (f .asinh (arg .expr ))
524554
525555
526556def atan (arg : Expr ) -> Expr :
527- """Returns inverse tangent of a number."""
557+ """Returns inverse tangent of a number.
558+
559+ Examples:
560+ ---------
561+ >>> ctx = dfn.SessionContext()
562+ >>> df = ctx.from_pydict({"a": [0.0]})
563+ >>> result = df.select(dfn.functions.atan(dfn.col("a")).alias("atan"))
564+ >>> result.collect_column("atan")[0].as_py()
565+ 0.0
566+ """
528567 return Expr (f .atan (arg .expr ))
529568
530569
531570def atanh (arg : Expr ) -> Expr :
532- """Returns inverse hyperbolic tangent."""
571+ """Returns inverse hyperbolic tangent.
572+
573+ Examples:
574+ ---------
575+ >>> ctx = dfn.SessionContext()
576+ >>> df = ctx.from_pydict({"a": [0.0]})
577+ >>> result = df.select(dfn.functions.atanh(dfn.col("a")).alias("atanh"))
578+ >>> result.collect_column("atanh")[0].as_py()
579+ 0.0
580+ """
533581 return Expr (f .atanh (arg .expr ))
534582
535583
536584def atan2 (y : Expr , x : Expr ) -> Expr :
537- """Returns inverse tangent of a division given in the argument."""
585+ """Returns inverse tangent of a division given in the argument.
586+
587+ Examples:
588+ ---------
589+ >>> ctx = dfn.SessionContext()
590+ >>> df = ctx.from_pydict({"y": [0.0], "x": [1.0]})
591+ >>> result = df.select(
592+ ... dfn.functions.atan2(dfn.col("y"), dfn.col("x")).alias("atan2"))
593+ >>> result.collect_column("atan2")[0].as_py()
594+ 0.0
595+ """
538596 return Expr (f .atan2 (y .expr , x .expr ))
539597
540598
@@ -585,22 +643,65 @@ def coalesce(*args: Expr) -> Expr:
585643
586644
587645def cos (arg : Expr ) -> Expr :
588- """Returns the cosine of the argument."""
646+ """Returns the cosine of the argument.
647+
648+ Examples:
649+ ---------
650+ >>> ctx = dfn.SessionContext()
651+ >>> df = ctx.from_pydict({"a": [0,-1,1]})
652+ >>> cos_df = df.select(dfn.functions.cos(dfn.col("a")).alias("cos"))
653+ >>> cos_df.collect_column("cos")[0].as_py()
654+ 1.0
655+ """
589656 return Expr (f .cos (arg .expr ))
590657
591658
592659def cosh (arg : Expr ) -> Expr :
593- """Returns the hyperbolic cosine of the argument."""
660+ """Returns the hyperbolic cosine of the argument.
661+
662+ Examples:
663+ ---------
664+ >>> ctx = dfn.SessionContext()
665+ >>> df = ctx.from_pydict({"a": [0,-1,1]})
666+ >>> cosh_df = df.select(dfn.functions.cosh(dfn.col("a")).alias("cosh"))
667+ >>> cosh_df.collect_column("cosh")[0].as_py()
668+ 1.0
669+ """
594670 return Expr (f .cosh (arg .expr ))
595671
596672
597673def cot (arg : Expr ) -> Expr :
598- """Returns the cotangent of the argument."""
674+ """Returns the cotangent of the argument.
675+
676+ Examples:
677+ ---------
678+ >>> from math import pi
679+ >>> ctx = dfn.SessionContext()
680+ >>> df = ctx.from_pydict({"a": [pi / 4]})
681+ >>> import builtins
682+ >>> result = df.select(
683+ ... dfn.functions.cot(dfn.col("a")).alias("cot")
684+ ... )
685+ >>> builtins.round(
686+ ... result.collect_column("cot")[0].as_py(), 1
687+ ... )
688+ 1.0
689+ """
599690 return Expr (f .cot (arg .expr ))
600691
601692
602693def degrees (arg : Expr ) -> Expr :
603- """Converts the argument from radians to degrees."""
694+ """Converts the argument from radians to degrees.
695+
696+ Examples:
697+ ---------
698+ >>> from math import pi
699+ >>> ctx = dfn.SessionContext()
700+ >>> df = ctx.from_pydict({"a": [0,pi,2*pi]})
701+ >>> deg_df = df.select(dfn.functions.degrees(dfn.col("a")).alias("deg"))
702+ >>> deg_df.collect_column("deg")[2].as_py()
703+ 360.0
704+ """
604705 return Expr (f .degrees (arg .expr ))
605706
606707
@@ -778,7 +879,22 @@ def pow(base: Expr, exponent: Expr) -> Expr:
778879
779880
780881def radians (arg : Expr ) -> Expr :
781- """Converts the argument from degrees to radians."""
882+ """Converts the argument from degrees to radians.
883+
884+ Examples:
885+ ---------
886+ >>> from math import pi
887+ >>> ctx = dfn.SessionContext()
888+ >>> df = ctx.from_pydict({"a": [180.0]})
889+ >>> import builtins
890+ >>> result = df.select(
891+ ... dfn.functions.radians(dfn.col("a")).alias("rad")
892+ ... )
893+ >>> builtins.round(
894+ ... result.collect_column("rad")[0].as_py(), 6
895+ ... )
896+ 3.141593
897+ """
782898 return Expr (f .radians (arg .expr ))
783899
784900
@@ -939,12 +1055,30 @@ def signum(arg: Expr) -> Expr:
9391055
9401056
9411057def sin (arg : Expr ) -> Expr :
942- """Returns the sine of the argument."""
1058+ """Returns the sine of the argument.
1059+
1060+ Examples:
1061+ ---------
1062+ >>> ctx = dfn.SessionContext()
1063+ >>> df = ctx.from_pydict({"a": [0.0]})
1064+ >>> result = df.select(dfn.functions.sin(dfn.col("a")).alias("sin"))
1065+ >>> result.collect_column("sin")[0].as_py()
1066+ 0.0
1067+ """
9431068 return Expr (f .sin (arg .expr ))
9441069
9451070
9461071def sinh (arg : Expr ) -> Expr :
947- """Returns the hyperbolic sine of the argument."""
1072+ """Returns the hyperbolic sine of the argument.
1073+
1074+ Examples:
1075+ ---------
1076+ >>> ctx = dfn.SessionContext()
1077+ >>> df = ctx.from_pydict({"a": [0.0]})
1078+ >>> result = df.select(dfn.functions.sinh(dfn.col("a")).alias("sinh"))
1079+ >>> result.collect_column("sinh")[0].as_py()
1080+ 0.0
1081+ """
9481082 return Expr (f .sinh (arg .expr ))
9491083
9501084
@@ -992,12 +1126,30 @@ def substring(string: Expr, position: Expr, length: Expr) -> Expr:
9921126
9931127
9941128def tan (arg : Expr ) -> Expr :
995- """Returns the tangent of the argument."""
1129+ """Returns the tangent of the argument.
1130+
1131+ Examples:
1132+ ---------
1133+ >>> ctx = dfn.SessionContext()
1134+ >>> df = ctx.from_pydict({"a": [0.0]})
1135+ >>> result = df.select(dfn.functions.tan(dfn.col("a")).alias("tan"))
1136+ >>> result.collect_column("tan")[0].as_py()
1137+ 0.0
1138+ """
9961139 return Expr (f .tan (arg .expr ))
9971140
9981141
9991142def tanh (arg : Expr ) -> Expr :
1000- """Returns the hyperbolic tangent of the argument."""
1143+ """Returns the hyperbolic tangent of the argument.
1144+
1145+ Examples:
1146+ ---------
1147+ >>> ctx = dfn.SessionContext()
1148+ >>> df = ctx.from_pydict({"a": [0.0]})
1149+ >>> result = df.select(dfn.functions.tanh(dfn.col("a")).alias("tanh"))
1150+ >>> result.collect_column("tanh")[0].as_py()
1151+ 0.0
1152+ """
10011153 return Expr (f .tanh (arg .expr ))
10021154
10031155
0 commit comments