You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/30 05:40:12 UTC

[GitHub] [spark] HyukjinKwon opened a new pull request, #37718: [SPARK-40270][PS] Make 'compute.max_rows' as None working in DataFrame.style

HyukjinKwon opened a new pull request, #37718:
URL: https://github.com/apache/spark/pull/37718

   ### What changes were proposed in this pull request?
   
   This PR make `compute.max_rows` option as `None` working in `DataFrame.style`, as expected instead of throwing an exception., by collecting it all to a pandas DataFrame.
   
   ### Why are the changes needed?
   
   To make the configuration working as expected.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes.
   
   ```python
   import pyspark.pandas as ps
   ps.set_option("compute.max_rows", None)
   ps.get_option("compute.max_rows")
   ps.range(1).style
   ```
   
   **Before:**
   
   ```
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/.../spark/python/pyspark/pandas/frame.py", line 3656, in style
       pdf = self.head(max_results + 1)._to_internal_pandas()
   TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
   ```
   
   **After:**
   
   ```
   <pandas.io.formats.style.Styler object at 0x7fdf78250430>
   ```
   
   ### How was this patch tested?
   
   Manually tested, and unittest was added.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #37718: [SPARK-40270][PS] Make 'compute.max_rows' as None working in DataFrame.style

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #37718:
URL: https://github.com/apache/spark/pull/37718#issuecomment-1231255546

   Merged to master.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] itholic commented on a diff in pull request #37718: [SPARK-40270][PS] Make 'compute.max_rows' as None working in DataFrame.style

Posted by GitBox <gi...@apache.org>.
itholic commented on code in PR #37718:
URL: https://github.com/apache/spark/pull/37718#discussion_r958233159


##########
python/pyspark/pandas/frame.py:
##########
@@ -3644,19 +3644,21 @@ def style(self) -> "Styler":
         Property returning a Styler object containing methods for
         building a styled HTML representation for the DataFrame.
 
-        .. note:: currently it collects top 1000 rows and return its
-            pandas `pandas.io.formats.style.Styler` instance.
-
         Examples
         --------
         >>> ps.range(1001).style  # doctest: +SKIP
         <pandas.io.formats.style.Styler object at ...>
         """
         max_results = get_option("compute.max_rows")
-        pdf = self.head(max_results + 1)._to_internal_pandas()
-        if len(pdf) > max_results:
-            warnings.warn("'style' property will only use top %s rows." % max_results, UserWarning)
-        return pdf.head(max_results).style
+        if max_results is not None:
+            pdf = self.head(max_results + 1)._to_internal_pandas()
+            if len(pdf) > max_results:
+                warnings.warn(
+                    "'style' property will only use top %s rows." % max_results, UserWarning
+                )
+            return pdf.head(max_results).style
+        else:
+            return self._to_internal_pandas().style

Review Comment:
   Nice fix! Thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #37718: [SPARK-40270][PS] Make 'compute.max_rows' as None working in DataFrame.style

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #37718:
URL: https://github.com/apache/spark/pull/37718#issuecomment-1231168314

   cc @itholic, @zhengruifeng, @xinrong-meng PTAL 🙏 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon closed pull request #37718: [SPARK-40270][PS] Make 'compute.max_rows' as None working in DataFrame.style

Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #37718: [SPARK-40270][PS] Make 'compute.max_rows' as None working in DataFrame.style
URL: https://github.com/apache/spark/pull/37718


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org