@@ -491,16 +491,28 @@ def abs(arg: Expr) -> Expr:
491491def acos (arg : Expr ) -> Expr :
492492 """Returns the arc cosine or inverse cosine of a number.
493493
494- Returns:
495- --------
496- Expr
497- A new expression representing the arc cosine of the input expression.
494+ Examples:
495+ ---------
496+ >>> ctx = dfn.SessionContext()
497+ >>> df = ctx.from_pydict({"a": [1.0]})
498+ >>> result = df.select(dfn.functions.acos(dfn.col("a")).alias("acos"))
499+ >>> result.collect_column("acos")[0].as_py()
500+ 0.0
498501 """
499502 return Expr (f .acos (arg .expr ))
500503
501504
502505def acosh (arg : Expr ) -> Expr :
503- """Returns inverse hyperbolic cosine."""
506+ """Returns inverse hyperbolic cosine.
507+
508+ Examples:
509+ ---------
510+ >>> ctx = dfn.SessionContext()
511+ >>> df = ctx.from_pydict({"a": [1.0]})
512+ >>> result = df.select(dfn.functions.acosh(dfn.col("a")).alias("acosh"))
513+ >>> result.collect_column("acosh")[0].as_py()
514+ 0.0
515+ """
504516 return Expr (f .acosh (arg .expr ))
505517
506518
@@ -510,27 +522,74 @@ def ascii(arg: Expr) -> Expr:
510522
511523
512524def asin (arg : Expr ) -> Expr :
513- """Returns the arc sine or inverse sine of a number."""
525+ """Returns the arc sine or inverse sine of a number.
526+
527+ Examples:
528+ ---------
529+ >>> ctx = dfn.SessionContext()
530+ >>> df = ctx.from_pydict({"a": [0.0]})
531+ >>> result = df.select(dfn.functions.asin(dfn.col("a")).alias("asin"))
532+ >>> result.collect_column("asin")[0].as_py()
533+ 0.0
534+ """
514535 return Expr (f .asin (arg .expr ))
515536
516537
517538def asinh (arg : Expr ) -> Expr :
518- """Returns inverse hyperbolic sine."""
539+ """Returns inverse hyperbolic sine.
540+
541+ Examples:
542+ ---------
543+ >>> ctx = dfn.SessionContext()
544+ >>> df = ctx.from_pydict({"a": [0.0]})
545+ >>> result = df.select(dfn.functions.asinh(dfn.col("a")).alias("asinh"))
546+ >>> result.collect_column("asinh")[0].as_py()
547+ 0.0
548+ """
519549 return Expr (f .asinh (arg .expr ))
520550
521551
522552def atan (arg : Expr ) -> Expr :
523- """Returns inverse tangent of a number."""
553+ """Returns inverse tangent of a number.
554+
555+ Examples:
556+ ---------
557+ >>> ctx = dfn.SessionContext()
558+ >>> df = ctx.from_pydict({"a": [0.0]})
559+ >>> result = df.select(dfn.functions.atan(dfn.col("a")).alias("atan"))
560+ >>> result.collect_column("atan")[0].as_py()
561+ 0.0
562+ """
524563 return Expr (f .atan (arg .expr ))
525564
526565
527566def atanh (arg : Expr ) -> Expr :
528- """Returns inverse hyperbolic tangent."""
567+ """Returns inverse hyperbolic tangent.
568+
569+ Examples:
570+ ---------
571+ >>> ctx = dfn.SessionContext()
572+ >>> df = ctx.from_pydict({"a": [0.0]})
573+ >>> result = df.select(dfn.functions.atanh(dfn.col("a")).alias("atanh"))
574+ >>> result.collect_column("atanh")[0].as_py()
575+ 0.0
576+ """
529577 return Expr (f .atanh (arg .expr ))
530578
531579
532580def atan2 (y : Expr , x : Expr ) -> Expr :
533- """Returns inverse tangent of a division given in the argument."""
581+ """Returns inverse tangent of a division given in the argument.
582+
583+ Examples:
584+ ---------
585+ >>> ctx = dfn.SessionContext()
586+ >>> df = ctx.from_pydict({"y": [0.0], "x": [1.0]})
587+ >>> result = df.select(
588+ ... dfn.functions.atan2(dfn.col("y"), dfn.col("x")).alias("atan2"))
589+ >>> result = result
590+ >>> result.collect_column("atan2")[0].as_py()
591+ 0.0
592+ """
534593 return Expr (f .atan2 (y .expr , x .expr ))
535594
536595
@@ -581,22 +640,65 @@ def coalesce(*args: Expr) -> Expr:
581640
582641
583642def cos (arg : Expr ) -> Expr :
584- """Returns the cosine of the argument."""
643+ """Returns the cosine of the argument.
644+
645+ Examples:
646+ ---------
647+ >>> ctx = dfn.SessionContext()
648+ >>> df = ctx.from_pydict({"a": [0,-1,1]})
649+ >>> cos_df = df.select(dfn.functions.cos(dfn.col("a")).alias("cos"))
650+ >>> cos_df.collect_column("cos")[0].as_py()
651+ 1.0
652+ """
585653 return Expr (f .cos (arg .expr ))
586654
587655
588656def cosh (arg : Expr ) -> Expr :
589- """Returns the hyperbolic cosine of the argument."""
657+ """Returns the hyperbolic cosine of the argument.
658+
659+ Examples:
660+ ---------
661+ >>> ctx = dfn.SessionContext()
662+ >>> df = ctx.from_pydict({"a": [0,-1,1]})
663+ >>> cosh_df = df.select(dfn.functions.cosh(dfn.col("a")).alias("cosh"))
664+ >>> cosh_df.collect_column("cosh")[0].as_py()
665+ 1.0
666+ """
590667 return Expr (f .cosh (arg .expr ))
591668
592669
593670def cot (arg : Expr ) -> Expr :
594- """Returns the cotangent of the argument."""
671+ """Returns the cotangent of the argument.
672+
673+ Examples:
674+ ---------
675+ >>> from math import pi
676+ >>> ctx = dfn.SessionContext()
677+ >>> df = ctx.from_pydict({"a": [pi / 4]})
678+ >>> import builtins
679+ >>> result = df.select(
680+ ... dfn.functions.cot(dfn.col("a")).alias("cot")
681+ ... )
682+ >>> builtins.round(
683+ ... result.collect_column("cot")[0].as_py(), 1
684+ ... )
685+ 1.0
686+ """
595687 return Expr (f .cot (arg .expr ))
596688
597689
598690def degrees (arg : Expr ) -> Expr :
599- """Converts the argument from radians to degrees."""
691+ """Converts the argument from radians to degrees.
692+
693+ Examples:
694+ ---------
695+ >>> from math import pi
696+ >>> ctx = dfn.SessionContext()
697+ >>> df = ctx.from_pydict({"a": [0,pi,2*pi]})
698+ >>> deg_df = df.select(dfn.functions.degrees(dfn.col("a")).alias("deg"))
699+ >>> deg_df.collect_column("deg")[2].as_py()
700+ 360.0
701+ """
600702 return Expr (f .degrees (arg .expr ))
601703
602704
@@ -774,7 +876,22 @@ def pow(base: Expr, exponent: Expr) -> Expr:
774876
775877
776878def radians (arg : Expr ) -> Expr :
777- """Converts the argument from degrees to radians."""
879+ """Converts the argument from degrees to radians.
880+
881+ Examples:
882+ ---------
883+ >>> from math import pi
884+ >>> ctx = dfn.SessionContext()
885+ >>> df = ctx.from_pydict({"a": [180.0]})
886+ >>> import builtins
887+ >>> result = df.select(
888+ ... dfn.functions.radians(dfn.col("a")).alias("rad")
889+ ... )
890+ >>> builtins.round(
891+ ... result.collect_column("rad")[0].as_py(), 6
892+ ... )
893+ 3.141593
894+ """
778895 return Expr (f .radians (arg .expr ))
779896
780897
@@ -935,12 +1052,30 @@ def signum(arg: Expr) -> Expr:
9351052
9361053
9371054def sin (arg : Expr ) -> Expr :
938- """Returns the sine of the argument."""
1055+ """Returns the sine of the argument.
1056+
1057+ Examples:
1058+ ---------
1059+ >>> ctx = dfn.SessionContext()
1060+ >>> df = ctx.from_pydict({"a": [0.0]})
1061+ >>> result = df.select(dfn.functions.sin(dfn.col("a")).alias("sin"))
1062+ >>> result.collect_column("sin")[0].as_py()
1063+ 0.0
1064+ """
9391065 return Expr (f .sin (arg .expr ))
9401066
9411067
9421068def sinh (arg : Expr ) -> Expr :
943- """Returns the hyperbolic sine of the argument."""
1069+ """Returns the hyperbolic sine of the argument.
1070+
1071+ Examples:
1072+ ---------
1073+ >>> ctx = dfn.SessionContext()
1074+ >>> df = ctx.from_pydict({"a": [0.0]})
1075+ >>> result = df.select(dfn.functions.sinh(dfn.col("a")).alias("sinh"))
1076+ >>> result.collect_column("sinh")[0].as_py()
1077+ 0.0
1078+ """
9441079 return Expr (f .sinh (arg .expr ))
9451080
9461081
@@ -988,12 +1123,30 @@ def substring(string: Expr, position: Expr, length: Expr) -> Expr:
9881123
9891124
9901125def tan (arg : Expr ) -> Expr :
991- """Returns the tangent of the argument."""
1126+ """Returns the tangent of the argument.
1127+
1128+ Examples:
1129+ ---------
1130+ >>> ctx = dfn.SessionContext()
1131+ >>> df = ctx.from_pydict({"a": [0.0]})
1132+ >>> result = df.select(dfn.functions.tan(dfn.col("a")).alias("tan"))
1133+ >>> result.collect_column("tan")[0].as_py()
1134+ 0.0
1135+ """
9921136 return Expr (f .tan (arg .expr ))
9931137
9941138
9951139def tanh (arg : Expr ) -> Expr :
996- """Returns the hyperbolic tangent of the argument."""
1140+ """Returns the hyperbolic tangent of the argument.
1141+
1142+ Examples:
1143+ ---------
1144+ >>> ctx = dfn.SessionContext()
1145+ >>> df = ctx.from_pydict({"a": [0.0]})
1146+ >>> result = df.select(dfn.functions.tanh(dfn.col("a")).alias("tanh"))
1147+ >>> result.collect_column("tanh")[0].as_py()
1148+ 0.0
1149+ """
9971150 return Expr (f .tanh (arg .expr ))
9981151
9991152
0 commit comments