Skip to content

Commit 386cb0a

Browse files
committed
fix
1 parent ba626ca commit 386cb0a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

python/pyspark/sql/tests/pandas/test_pandas_grouped_map.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import unittest
2020
import logging
2121
import os
22+
import copy
2223

2324
from collections import OrderedDict
2425
from decimal import Decimal
@@ -289,17 +290,19 @@ def stats_with_no_column_names(key, pdf):
289290
return pd.DataFrame([key + (pdf.v.mean(),)])
290291

291292
def test_apply_in_pandas_returning_column_names(self):
292-
self._test_apply_in_pandas(ApplyInPandasTestsMixin.stats_with_column_names)
293+
self._test_apply_in_pandas(copy.deepcopy(ApplyInPandasTestsMixin.stats_with_column_names))
293294

294295
def test_apply_in_pandas_returning_no_column_names(self):
295-
self._test_apply_in_pandas(ApplyInPandasTestsMixin.stats_with_no_column_names)
296+
self._test_apply_in_pandas(copy.deepcopy(ApplyInPandasTestsMixin.stats_with_no_column_names))
296297

297298
def test_apply_in_pandas_returning_column_names_sometimes(self):
299+
f = copy.deepcopy(ApplyInPandasTestsMixin.stats_with_column_names)
300+
298301
def stats(key, pdf):
299302
if key[0] % 2:
300-
return ApplyInPandasTestsMixin.stats_with_column_names(key, pdf)
303+
return f(key, pdf)
301304
else:
302-
return ApplyInPandasTestsMixin.stats_with_no_column_names(key, pdf)
305+
return f(key, pdf)
303306

304307
self._test_apply_in_pandas(stats)
305308

@@ -869,10 +872,11 @@ def _test_apply_in_pandas(self, f, output_schema="id long, mean double"):
869872
def _test_apply_in_pandas_returning_empty_dataframe(self, empty_df):
870873
"""Tests some returned DataFrames are empty."""
871874
df = self.data
875+
f = copy.deepcopy(ApplyInPandasTestsMixin.stats_with_no_column_names)
872876

873877
def stats(key, pdf):
874878
if key[0] % 2 == 0:
875-
return ApplyInPandasTestsMixin.stats_with_no_column_names(key, pdf)
879+
return f(key, pdf)
876880
return empty_df
877881

878882
result = (

0 commit comments

Comments
 (0)