Skip to content

Instantly share code, notes, and snippets.

@khuyentran1401
Created December 3, 2021 17:56
Show Gist options
  • Save khuyentran1401/091f7439eadbbecdb9b3ad875b30f17a to your computer and use it in GitHub Desktop.
Save khuyentran1401/091f7439eadbbecdb9b3ad875b30f17a to your computer and use it in GitHub Desktop.
# schema: *
def get_median(df: pd.DataFrame) -> List[Dict[str, Any]]:
return [{"col1": df["col1"].median(), "col2": df["col2"].iloc[0]}]
%%fsql spark
SELECT *
FROM df
TRANSFORM PREPARTITION BY col2 USING get_median
PRINT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment