Skip to content

Commit

Permalink
Add a manual test
Browse files Browse the repository at this point in the history
  • Loading branch information
icexelloss committed Jan 18, 2018
1 parent 0fec5cf commit 4d22107
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions python/pyspark/sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4408,6 +4408,27 @@ def weighted_mean(v, w):
return np.average(v, weights=w)
return weighted_mean

def test_manual(self):
df = self.data
sum_udf = self.pandas_agg_sum_udf
mean_udf = self.pandas_agg_mean_udf

result1 = df.groupby('id').agg(sum_udf(df.v), mean_udf(df.v)).sort('id')
expected1 = self.spark.createDataFrame(
[[0, 245.0, 24.5],
[1, 255.0, 25.5],
[2, 265.0, 26.5],
[3, 275.0, 27.5],
[4, 285.0, 28.5],
[5, 295.0, 29.5],
[6, 305.0, 30.5],
[7, 315.0, 31.5],
[8, 325.0, 32.5],
[9, 335.0, 33.5]],
['id', 'sum(v)', 'avg(v)'])

self.assertPandasEqual(expected1.toPandas(), result1.toPandas())

def test_basic(self):
from pyspark.sql.functions import col, lit, sum, mean

Expand Down

0 comments on commit 4d22107

Please sign in to comment.