dcoliversun commented on code in PR #37444:
URL: https://github.com/apache/spark/pull/37444#discussion_r953483561


##########
python/pyspark/sql/dataframe.py:
##########
@@ -1375,8 +1437,17 @@ def dtypes(self) -> List[Tuple[str, str]]:
 
         Examples
         --------
+        >>> df = spark.createDataFrame([(14, "Tom"),
+        ... (23, "Alice")], ["age", "name"])

Review Comment:
   ```suggestion
           >>> df = spark.createDataFrame([(14, "Tom"),
           ...     (23, "Alice")], ["age", "name"])
   ```



##########
python/pyspark/sql/dataframe.py:
##########
@@ -2899,7 +3022,20 @@ def replace(  # type: ignore[misc]
         |null|  null|null|
         +----+------+----+
 
-        >>> df4.na.replace(['Alice', 'Bob'], ['A', 'B'], 'name').show()
+        Replace all instances of Alice to 'A' and Bob to 'B' under the name 
column
+        
+        >>> df = spark.createDataFrame([(10, 80, "Alice"), (5, None, "Bob"),

Review Comment:
   Why do we need to create duplicate dataframe here? If we don't need it, 
better to delete
   ```shell
   >>> df = spark.createDataFrame([(10, 80, "Alice"), (5, None, "Bob"),(None, 
None, "Tom"), (None, None, None)], ["age", "height", "name"])
   >>> df.show()
   +----+------+-----+                                                          
   
   | age|height| name|
   +----+------+-----+
   |  10|    80|Alice|
   |   5|  null|  Bob|
   |null|  null|  Tom|
   |null|  null| null|
   +----+------+-----+
   
   >>> df.na.replace('Alice', None).show()
   +----+------+----+
   | age|height|name|
   +----+------+----+
   |  10|    80|null|
   |   5|  null| Bob|
   |null|  null| Tom|
   |null|  null|null|
   +----+------+----+
   
   >>> df.show()
   +----+------+-----+
   | age|height| name|
   +----+------+-----+
   |  10|    80|Alice|
   |   5|  null|  Bob|
   |null|  null|  Tom|
   |null|  null| null|
   +----+------+-----+
   
   >>> df.na.replace(['Alice', 'Bob'], ['A', 'B'], 'name').show()
   +----+------+----+
   | age|height|name|
   +----+------+----+
   |  10|    80|   A|
   |   5|  null|   B|
   |null|  null| Tom|
   |null|  null|null|
   +----+------+----+
   ```



##########
python/pyspark/sql/dataframe.py:
##########
@@ -1179,6 +1231,16 @@ def distinct(self) -> "DataFrame":
 
         Examples
         --------
+        >>> df = spark.createDataFrame([(14, "Tom"), (23, "Alice"),
+        ... (23, "Alice")], ["age", "name"]) 

Review Comment:
   ```suggestion
           >>> df = spark.createDataFrame([(14, "Tom"), (23, "Alice"),
           ...     (23, "Alice")], ["age", "name"]) 
   ```



##########
python/pyspark/sql/dataframe.py:
##########
@@ -2869,7 +2978,18 @@ def replace(  # type: ignore[misc]
 
         Examples
         --------
-        >>> df4.na.replace(10, 20).show()
+        >>> df = spark.createDataFrame([(10, 80, "Alice"), (5, None, "Bob"),
+        ... (None, None, "Tom"), (None, None, None)], ["age", "height", 
"name"])

Review Comment:
   ```suggestion
           >>> df = spark.createDataFrame([(10, 80, "Alice"), (5, None, "Bob"),
           ...     (None, None, "Tom"), (None, None, None)], ["age", "height", 
"name"])
   ```



##########
python/pyspark/sql/dataframe.py:
##########
@@ -2762,7 +2858,20 @@ def fillna(
         |null|Mallory| true|
         +----+-------+-----+
 
-        >>> df4.na.fill({'age': 50, 'name': 'unknown'}).show()
+       Fill all null values in the 'age' column to 50 and "unknown" in the 
'name' column
+       
+        >>> df = spark.createDataFrame([(10, 80, "Alice"), (5, None, "Bob"),
+        ... (None, None, "Tom"), (None, None, None)], ["age", "height", 
"name"])

Review Comment:
   ```suggestion
           >>> df = spark.createDataFrame([(10, 80, "Alice"), (5, None, "Bob"),
           ...     (None, None, "Tom"), (None, None, None)], ["age", "height", 
"name"])
   ```



##########
python/pyspark/sql/dataframe.py:
##########
@@ -878,8 +920,18 @@ def tail(self, num: int) -> List[Row]:
 
         Examples
         --------
-        >>> df.tail(1)
-        [Row(age=5, name='Bob')]
+        >>> df = spark.createDataFrame([(14, "Tom"), (23, "Alice"),
+        ... (16, "Bob")], ["age", "name"])

Review Comment:
   ```suggestion
           >>> df = spark.createDataFrame([(14, "Tom"), (23, "Alice"),
           ...     (16, "Bob")], ["age", "name"])
   ```



##########
python/pyspark/sql/dataframe.py:
##########
@@ -2753,7 +2837,19 @@ def fillna(
         | 50|    50| null|
         +---+------+-----+
 
-        >>> df5.na.fill(False).show()
+       Fill all null values with False when the data type of the column is a 
boolean
+
+        >>> df = spark.createDataFrame([(10, "Alice", None), (5, "Bob", None),
+        ... (None, "Mallory", True)], ["age", "name", "spy"])

Review Comment:
   ```suggestion
           >>> df = spark.createDataFrame([(10, "Alice", None), (5, "Bob", 
None),
           ...     (None, "Mallory", True)], ["age", "name", "spy"])
   ```



-- 
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