@@ -1014,7 +1014,7 @@ def iterrows(self) -> Iterable[Tuple[Label, Series]]:
1014
1014
s = klass (v , index = columns , name = k )
1015
1015
yield k , s
1016
1016
1017
- def itertuples (self , index = True , name = "Pandas" ):
1017
+ def itertuples (self , index : bool = True , name : Optional [ str ] = "Pandas" ):
1018
1018
"""
1019
1019
Iterate over DataFrame rows as namedtuples.
1020
1020
@@ -1088,7 +1088,11 @@ def itertuples(self, index=True, name="Pandas"):
1088
1088
arrays .extend (self .iloc [:, k ] for k in range (len (self .columns )))
1089
1089
1090
1090
if name is not None :
1091
- itertuple = collections .namedtuple (name , fields , rename = True )
1091
+ # https://github.com/python/mypy/issues/9046
1092
+ # error: namedtuple() expects a string literal as the first argument
1093
+ itertuple = collections .namedtuple ( # type: ignore[misc]
1094
+ name , fields , rename = True
1095
+ )
1092
1096
return map (itertuple ._make , zip (* arrays ))
1093
1097
1094
1098
# fallback to regular tuples
@@ -4591,7 +4595,7 @@ def set_index(
4591
4595
frame = self .copy ()
4592
4596
4593
4597
arrays = []
4594
- names = []
4598
+ names : List [ Label ] = []
4595
4599
if append :
4596
4600
names = list (self .index .names )
4597
4601
if isinstance (self .index , MultiIndex ):
0 commit comments