TypeError: Type Tuple cannot be instantiated; use tuple() instead

Use square brackets:

Tuple[pd.DataFrame, pd.DataFrame]

From the docs:

Tuple type; Tuple[X, Y] is the type of a tuple of two items with the first item of type X and the second of type Y. The type of the empty tuple can be written as Tuple[()].

EDIT: With the release of python 3.9, you can now do this with the builtins.tuple type rather than having to import typing. For example:

>>> tuple[pd.DataFrame, pd.DataFrame]
tuple[pandas.core.frame.DataFrame, pandas.core.frame.DataFrame]

You still have to use square brackets.

Leave a Comment

tech