timsaucer commented on code in PR #909:
URL: https://github.com/apache/datafusion-python/pull/909#discussion_r1800854864


##########
python/datafusion/dataframe.py:
##########
@@ -160,6 +160,53 @@ def with_column(self, name: str, expr: Expr) -> DataFrame:
         """
         return DataFrame(self.df.with_column(name, expr.expr))
 
+    def with_columns(
+        self, *exprs: Expr | Iterable[Expr], **named_exprs: Expr
+    ) -> DataFrame:
+        """Add columns to the DataFrame.
+
+        By passing expressions, iteratables of expressions, or named 
expressions. To
+        pass named expressions use the form name=Expr.
+
+        Example usage:
+
+            The following will add 4 columns labeled a, b, c, and d.
+
+            df = df.with_columns(
+                lit(0).alias('a'),
+                [lit(1).alias('b'), lit(2).alias('c')],
+                d=lit(3)
+                )
+
+        Args:
+            *exprs: Name of the column to add.
+            **named_exprs: Expression to compute the column.
+
+        Returns:
+            DataFrame with the new column.
+        """

Review Comment:
   ```suggestion
       def with_columns(
           self, *exprs: Expr | Iterable[Expr], **named_exprs: Expr
       ) -> DataFrame:
           """Add columns to the DataFrame.
   
           By passing expressions, iteratables of expressions, or named 
expressions. To
           pass named expressions use the form name=Expr.
   
           Example usage: The following will add 4 columns labeled a, b, c, and 
d::
   
               df = df.with_columns(
                   lit(0).alias('a'),
                   [lit(1).alias('b'), lit(2).alias('c')],
                   d=lit(3)
                   )
   
           Args:
               exprs: Either a single expression or an iterable of expressions 
to add.
               named_exprs: Named expressions in the form of ``name=expr``
   
           Returns:
               DataFrame with the new columns added.
           """
   ```
   ```suggestion
       def with_columns(
           self, *exprs: Expr | Iterable[Expr], **named_exprs: Expr
       ) -> DataFrame:
           """Add columns to the DataFrame.
   
           By passing expressions, iteratables of expressions, or named 
expressions. To
           pass named expressions use the form name=Expr.
   
           Example usage:
   
               The following will add 4 columns labeled a, b, c, and d.
   
               df = df.with_columns(
                   lit(0).alias('a'),
                   [lit(1).alias('b'), lit(2).alias('c')],
                   d=lit(3)
                   )
   
           Args:
               *exprs: Name of the column to add.
               **named_exprs: Expression to compute the column.
   
           Returns:
               DataFrame with the new column.
           """
   ```



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