@@ -262,6 +262,39 @@ public actor DataFrame: Sendable {
262
262
return DataFrame ( spark: self . spark, plan: SparkConnectClient . getProject ( self . plan. root, cols) )
263
263
}
264
264
265
+ /// Returns a new Dataset with a column dropped. This is a no-op if schema doesn't contain column name.
266
+ /// - Parameter cols: Column names
267
+ /// - Returns: A ``DataFrame`` with subset of columns.
268
+ public func drop( _ cols: String ... ) -> DataFrame {
269
+ return DataFrame ( spark: self . spark, plan: SparkConnectClient . getDrop ( self . plan. root, cols) )
270
+ }
271
+
272
+ /// Returns a new Dataset with a column renamed. This is a no-op if schema doesn't contain existingName.
273
+ /// - Parameters:
274
+ /// - existingName: A existing column name to be renamed.
275
+ /// - newName: A new column name.
276
+ /// - Returns: A ``DataFrame`` with the renamed column.
277
+ public func withColumnRenamed( _ existingName: String , _ newName: String ) -> DataFrame {
278
+ return withColumnRenamed ( [ existingName: newName] )
279
+ }
280
+
281
+ /// Returns a new Dataset with columns renamed. This is a no-op if schema doesn't contain existingName.
282
+ /// - Parameters:
283
+ /// - colNames: A list of existing colum names to be renamed.
284
+ /// - newColNames: A list of new column names.
285
+ /// - Returns: A ``DataFrame`` with the renamed columns.
286
+ public func withColumnRenamed( _ colNames: [ String ] , _ newColNames: [ String ] ) -> DataFrame {
287
+ let dic = Dictionary ( uniqueKeysWithValues: zip ( colNames, newColNames) )
288
+ return DataFrame ( spark: self . spark, plan: SparkConnectClient . getWithColumnRenamed ( self . plan. root, dic) )
289
+ }
290
+
291
+ /// Returns a new Dataset with columns renamed. This is a no-op if schema doesn't contain existingName.
292
+ /// - Parameter colsMap: A dictionary of existing column name and new column name.
293
+ /// - Returns: A ``DataFrame`` with the renamed columns.
294
+ public func withColumnRenamed( _ colsMap: [ String : String ] ) -> DataFrame {
295
+ return DataFrame ( spark: self . spark, plan: SparkConnectClient . getWithColumnRenamed ( self . plan. root, colsMap) )
296
+ }
297
+
265
298
/// Return a new ``DataFrame`` with filtered rows using the given expression.
266
299
/// - Parameter conditionExpr: A string to filter.
267
300
/// - Returns: A ``DataFrame`` with subset of rows.
0 commit comments