@@ -143,7 +143,7 @@ def withColumn(self, columnName: str, col: Column) -> "DataFrame":
143143 rel = self .relation .select (* cols )
144144 return DataFrame (rel , self .session )
145145
146- def withColumns (self , * colsMap : Dict [str , Column ]) -> "DataFrame" :
146+ def withColumns (self , * colsMap : dict [str , Column ]) -> "DataFrame" :
147147 """
148148 Returns a new :class:`DataFrame` by adding multiple columns or replacing the
149149 existing columns that have the same names.
@@ -218,7 +218,7 @@ def withColumns(self, *colsMap: Dict[str, Column]) -> "DataFrame":
218218 rel = self .relation .select (* cols )
219219 return DataFrame (rel , self .session )
220220
221- def withColumnsRenamed (self , colsMap : Dict [str , str ]) -> "DataFrame" :
221+ def withColumnsRenamed (self , colsMap : dict [str , str ]) -> "DataFrame" :
222222 """
223223 Returns a new :class:`DataFrame` by renaming multiple columns.
224224 This is a no-op if the schema doesn't contain the given column names.
@@ -356,7 +356,7 @@ def transform(
356356 return result
357357
358358 def sort (
359- self , * cols : Union [str , Column , List [Union [str , Column ]]], ** kwargs : Any
359+ self , * cols : Union [str , Column , list [Union [str , Column ]]], ** kwargs : Any
360360 ) -> "DataFrame" :
361361 """Returns a new :class:`DataFrame` sorted by the specified column(s).
362362
@@ -487,15 +487,15 @@ def sort(
487487
488488 orderBy = sort
489489
490- def head (self , n : Optional [int ] = None ) -> Union [Optional [Row ], List [Row ]]:
490+ def head (self , n : Optional [int ] = None ) -> Union [Optional [Row ], list [Row ]]:
491491 if n is None :
492492 rs = self .head (1 )
493493 return rs [0 ] if rs else None
494494 return self .take (n )
495495
496496 first = head
497497
498- def take (self , num : int ) -> List [Row ]:
498+ def take (self , num : int ) -> list [Row ]:
499499 return self .limit (num ).collect ()
500500
501501 def filter (self , condition : "ColumnOrName" ) -> "DataFrame" :
@@ -579,7 +579,7 @@ def select(self, *cols) -> "DataFrame":
579579 return DataFrame (rel , self .session )
580580
581581 @property
582- def columns (self ) -> List [str ]:
582+ def columns (self ) -> list [str ]:
583583 """Returns all column names as a list.
584584
585585 Examples
@@ -589,20 +589,20 @@ def columns(self) -> List[str]:
589589 """
590590 return [f .name for f in self .schema .fields ]
591591
592- def _ipython_key_completions_ (self ) -> List [str ]:
592+ def _ipython_key_completions_ (self ) -> list [str ]:
593593 # Provides tab-completion for column names in PySpark DataFrame
594594 # when accessed in bracket notation, e.g. df['<TAB>]
595595 return self .columns
596596
597- def __dir__ (self ) -> List [str ]:
597+ def __dir__ (self ) -> list [str ]:
598598 out = set (super ().__dir__ ())
599599 out .update (c for c in self .columns if c .isidentifier () and not iskeyword (c ))
600600 return sorted (out )
601601
602602 def join (
603603 self ,
604604 other : "DataFrame" ,
605- on : Optional [Union [str , List [str ], Column , List [Column ]]] = None ,
605+ on : Optional [Union [str , list [str ], Column , list [Column ]]] = None ,
606606 how : Optional [str ] = None ,
607607 ) -> "DataFrame" :
608608 """Joins with another :class:`DataFrame`, using the given join expression.
@@ -704,7 +704,7 @@ def join(
704704 assert isinstance (
705705 on [0 ], Expression
706706 ), "on should be Column or list of Column"
707- on = reduce (lambda x , y : x .__and__ (y ), cast (List [Expression ], on ))
707+ on = reduce (lambda x , y : x .__and__ (y ), cast (list [Expression ], on ))
708708
709709
710710 if on is None and how is None :
@@ -893,11 +893,11 @@ def __getitem__(self, item: Union[int, str]) -> Column:
893893 ...
894894
895895 @overload
896- def __getitem__ (self , item : Union [Column , List , Tuple ]) -> "DataFrame" :
896+ def __getitem__ (self , item : Union [Column , list , tuple ]) -> "DataFrame" :
897897 ...
898898
899899 def __getitem__ (
900- self , item : Union [int , str , Column , List , Tuple ]
900+ self , item : Union [int , str , Column , list , tuple ]
901901 ) -> Union [Column , "DataFrame" ]:
902902 """Returns the column as a :class:`Column`.
903903
@@ -942,7 +942,7 @@ def groupBy(self, *cols: "ColumnOrName") -> "GroupedData":
942942 ...
943943
944944 @overload
945- def groupBy (self , __cols : Union [List [Column ], List [str ]]) -> "GroupedData" :
945+ def groupBy (self , __cols : Union [list [Column ], list [str ]]) -> "GroupedData" :
946946 ...
947947
948948 def groupBy (self , * cols : "ColumnOrName" ) -> "GroupedData" : # type: ignore[misc]
@@ -1259,7 +1259,7 @@ def exceptAll(self, other: "DataFrame") -> "DataFrame":
12591259 """
12601260 return DataFrame (self .relation .except_ (other .relation ), self .session )
12611261
1262- def dropDuplicates (self , subset : Optional [List [str ]] = None ) -> "DataFrame" :
1262+ def dropDuplicates (self , subset : Optional [list [str ]] = None ) -> "DataFrame" :
12631263 """Return a new :class:`DataFrame` with duplicate rows removed,
12641264 optionally only considering certain columns.
12651265
@@ -1391,7 +1391,7 @@ def toDF(self, *cols) -> "DataFrame":
13911391 new_rel = self .relation .project (* projections )
13921392 return DataFrame (new_rel , self .session )
13931393
1394- def collect (self ) -> List [Row ]:
1394+ def collect (self ) -> list [Row ]:
13951395 columns = self .relation .columns
13961396 result = self .relation .fetchall ()
13971397
0 commit comments