File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
spec/API_specification/dataframe_api Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -995,10 +995,11 @@ def persist(self) -> Self:
995
995
.. code-block:: python
996
996
997
997
df: DataFrame
998
- df = df.persist()
999
998
features = []
999
+ result = df.std() > 0
1000
+ result = result.persist()
1000
1001
for column_name in df.column_names:
1001
- if df .col(column_name).std() > 0 :
1002
+ if result .col(column_name).get_value(0) :
1002
1003
features.append(column_name)
1003
1004
1004
1005
instead of this:
@@ -1008,7 +1009,8 @@ def persist(self) -> Self:
1008
1009
df: DataFrame
1009
1010
features = []
1010
1011
for column_name in df.column_names:
1011
- # Do NOT do this!
1012
+ # Do NOT call `persist` on a `DataFrame` within a for-loop!
1013
+ # This may re-trigger the same computation multiple times
1012
1014
if df.persist().col(column_name).std() > 0:
1013
1015
features.append(column_name)
1014
1016
"""
You can’t perform that action at this time.
0 commit comments