Skip to content

Commit f46ebe8

Browse files
TYP: misc typing fixes for pandas\core\frame.py (#35990)
* TYP: misc typing fixes for pandas\core\frame.py * correct issue number
1 parent b45327f commit f46ebe8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pandas/core/frame.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def iterrows(self) -> Iterable[Tuple[Label, Series]]:
10141014
s = klass(v, index=columns, name=k)
10151015
yield k, s
10161016

1017-
def itertuples(self, index=True, name="Pandas"):
1017+
def itertuples(self, index: bool = True, name: Optional[str] = "Pandas"):
10181018
"""
10191019
Iterate over DataFrame rows as namedtuples.
10201020
@@ -1088,7 +1088,11 @@ def itertuples(self, index=True, name="Pandas"):
10881088
arrays.extend(self.iloc[:, k] for k in range(len(self.columns)))
10891089

10901090
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+
)
10921096
return map(itertuple._make, zip(*arrays))
10931097

10941098
# fallback to regular tuples
@@ -4591,7 +4595,7 @@ def set_index(
45914595
frame = self.copy()
45924596

45934597
arrays = []
4594-
names = []
4598+
names: List[Label] = []
45954599
if append:
45964600
names = list(self.index.names)
45974601
if isinstance(self.index, MultiIndex):

0 commit comments

Comments
 (0)