itholic commented on code in PR #37294:
URL: https://github.com/apache/spark/pull/37294#discussion_r930559962


##########
python/pyspark/pandas/tests/test_dataframe.py:
##########
@@ -6562,6 +6619,23 @@ def test_cov(self):
         psdf = ps.from_pandas(pdf)
         self.assert_eq(pdf.cov(), psdf.cov())
 
+    def test_style(self):
+        # Currently, the `style` function returns a pandas object `Styler` as 
it is,
+        # processing only the number of rows declared in `compute.max_rows`.
+        # So it's a bit vague to test, but we are doing minimal tests instead 
of not testing at all.
+        pdf = pd.DataFrame(np.random.randn(10, 4), columns=["A", "B", "C", 
"D"])
+        psdf = ps.from_pandas(pdf)
+
+        def style_negative(v, props=""):
+            return props if v < 0 else None
+
+        # If the value is negative, the text color will be displayed as red.
+        pdf_style = pdf.style.applymap(style_negative, props="color:red;")
+        psdf_style = psdf.style.applymap(style_negative, props="color:red;")
+
+        # Test whether the same shape as pandas table is created including the 
color.
+        self.assert_eq(pdf_style.to_latex(), psdf_style.to_latex())

Review Comment:
   This test basically check with the latex text that the function 
"style_negative" is properly reflected.
   
   This can also be visually confirmed as follows:
   
   ![Screen Shot 2022-07-27 at 11 23 00 
AM](https://user-images.githubusercontent.com/44108233/181146744-fd50fadb-54c4-475c-8c4f-8e39f0b76119.png)
   
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to