Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always pass Column to pandas.spark.functions #1712

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions narwhals/_spark_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def maybe_evaluate(df: SparkLikeLazyFrame, obj: Any) -> Any:


def _std(
_input: Column,
_input: Column | str,
ddof: int,
backend_version: tuple[int, ...],
np_version: tuple[int, ...],
Expand All @@ -136,12 +136,14 @@ def _std(
return F.stddev_samp(_input) * F.sqrt((n_rows - 1) / (n_rows - ddof))

from pyspark.pandas.spark.functions import stddev
from pyspark.sql import functions as F # noqa: N812

return stddev(_input, ddof=ddof)
input_col = F.col(_input) if isinstance(_input, str) else _input
return stddev(input_col, ddof=ddof)


def _var(
_input: Column,
_input: Column | str,
ddof: int,
backend_version: tuple[int, ...],
np_version: tuple[int, ...],
Expand All @@ -156,5 +158,7 @@ def _var(
return F.var_samp(_input) * (n_rows - 1) / (n_rows - ddof)

from pyspark.pandas.spark.functions import var
from pyspark.sql import functions as F # noqa: N812

return var(_input, ddof=ddof)
input_col = F.col(_input) if isinstance(_input, str) else _input
return var(input_col, ddof=ddof)
Loading