Skip to content

Commit c531096

Browse files
authored
Add UDF type hinting (#8361)
* fixed jvm error * add type hinting to UDF
1 parent 80e3f12 commit c531096

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

composer/2022_airflow_summit/data_analytics_process_expansion.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103

104104
# Inverse Distance Weighting algorithm (DWA)
105105
@f.pandas_udf("YEAR integer, VALUE double", f.PandasUDFType.GROUPED_MAP)
106-
def phx_dw_compute(year, df) -> pd.DataFrame:
106+
def phx_dw_compute(year: tuple, df: pd.DataFrame) -> pd.DataFrame:
107107
# This adjusts the rainfall / snowfall in Phoenix for a given year using Inverse Distance Weighting
108108
# based on each weather station's distance to Phoenix. The closer a station is to Phoenix, the higher
109109
# its measurement is weighed.
@@ -119,6 +119,13 @@ def phx_dw_compute(year, df) -> pd.DataFrame:
119119
# so we negate the square and square root to combine this into:
120120
#
121121
# idf = 1 / ((x1-x2)^2 + (y1-y2)^2))
122+
#
123+
# Args:
124+
# year: a tuple containing a single 4-digit integer value for this group's year
125+
# df: a pandas dataframe
126+
#
127+
# Returns:
128+
# A new pandas dataframe
122129

123130
# Latitude and longitude of Phoenix
124131
PHX_LATITUDE = 33.4484

0 commit comments

Comments
 (0)