@@ -1859,6 +1859,18 @@ def to_char(arg: Expr, formatter: Expr) -> Expr:
18591859 For usage of ``formatter`` see the rust chrono package ``strftime`` package.
18601860
18611861 [Documentation here.](https://docs.rs/chrono/latest/chrono/format/strftime/index.html)
1862+
1863+ Examples:
1864+ >>> ctx = dfn.SessionContext()
1865+ >>> df = ctx.from_pydict({"a": ["2021-01-01T00:00:00"]})
1866+ >>> result = df.select(
1867+ ... dfn.functions.to_char(
1868+ ... dfn.functions.to_timestamp(dfn.col("a")),
1869+ ... dfn.lit("%Y/%m/%d"),
1870+ ... ).alias("formatted")
1871+ ... )
1872+ >>> result.collect_column("formatted")[0].as_py()
1873+ '2021/01/01'
18621874 """
18631875 return Expr (f .to_char (arg .expr , formatter .expr ))
18641876
@@ -1878,6 +1890,14 @@ def to_date(arg: Expr, *formatters: Expr) -> Expr:
18781890 For usage of ``formatters`` see the rust chrono package ``strftime`` package.
18791891
18801892 [Documentation here.](https://docs.rs/chrono/latest/chrono/format/strftime/index.html)
1893+
1894+ Examples:
1895+ >>> ctx = dfn.SessionContext()
1896+ >>> df = ctx.from_pydict({"a": ["2021-07-20"]})
1897+ >>> result = df.select(
1898+ ... dfn.functions.to_date(dfn.col("a")).alias("dt"))
1899+ >>> str(result.collect_column("dt")[0].as_py())
1900+ '2021-07-20'
18811901 """
18821902 return Expr (f .to_date (arg .expr , * _unwrap_exprs (formatters )))
18831903
@@ -1899,6 +1919,14 @@ def to_time(arg: Expr, *formatters: Expr) -> Expr:
18991919 For usage of ``formatters`` see the rust chrono package ``strftime`` package.
19001920
19011921 [Documentation here.](https://docs.rs/chrono/latest/chrono/format/strftime/index.html)
1922+
1923+ Examples:
1924+ >>> ctx = dfn.SessionContext()
1925+ >>> df = ctx.from_pydict({"a": ["14:30:00"]})
1926+ >>> result = df.select(
1927+ ... dfn.functions.to_time(dfn.col("a")).alias("t"))
1928+ >>> str(result.collect_column("t")[0].as_py())
1929+ '14:30:00'
19021930 """
19031931 return Expr (f .to_time (arg .expr , * _unwrap_exprs (formatters )))
19041932
@@ -3730,15 +3758,6 @@ def var_sample(expression: Expr, filter: Expr | None = None) -> Expr:
37303758 """Computes the sample variance of the argument.
37313759
37323760 This is an alias for :py:func:`var_samp`.
3733-
3734- Examples:
3735- >>> ctx = dfn.SessionContext()
3736- >>> df = ctx.from_pydict({"a": [1.0, 2.0, 3.0]})
3737- >>> result = df.aggregate(
3738- ... [], [dfn.functions.var_sample(dfn.col("a")).alias("v")]
3739- ... )
3740- >>> result.collect_column("v")[0].as_py()
3741- 1.0
37423761 """
37433762 return var_samp (expression , filter )
37443763
0 commit comments