diff --git a/pandas/core/generic.py b/pandas/core/generic.py index bbdb88a4b04a7..fc15c846b1907 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2625,7 +2625,7 @@ def to_hdf( min_itemsize: int | dict[str, int] | None = None, nan_rep=None, dropna: bool_t | None = None, - data_columns: bool_t | list[str] | None = None, + data_columns: Literal[True] | list[str] | None = None, errors: str = "strict", encoding: str = "UTF-8", ) -> None: diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index ef9026a870423..3ce5cb31a127a 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -19,6 +19,7 @@ Any, Callable, Hashable, + Literal, Sequence, cast, ) @@ -272,7 +273,7 @@ def to_hdf( min_itemsize: int | dict[str, int] | None = None, nan_rep=None, dropna: bool | None = None, - data_columns: bool | list[str] | None = None, + data_columns: Literal[True] | list[str] | None = None, errors: str = "strict", encoding: str = "UTF-8", ) -> None: @@ -1078,7 +1079,7 @@ def put( complevel: int | None = None, min_itemsize: int | dict[str, int] | None = None, nan_rep=None, - data_columns: list[str] | None = None, + data_columns: Literal[True] | list[str] | None = None, encoding=None, errors: str = "strict", track_times: bool = True, @@ -1102,7 +1103,7 @@ def put( subsets of the data. append : bool, default False This will force Table format, append the input data to the existing. - data_columns : list, default None + data_columns : list of columns or True, default None List of columns to create as data columns, or True to use all columns. See `here `__. @@ -1208,7 +1209,7 @@ def append( chunksize=None, expectedrows=None, dropna: bool | None = None, - data_columns: list[str] | None = None, + data_columns: Literal[True] | list[str] | None = None, encoding=None, errors: str = "strict", ): @@ -3263,8 +3264,7 @@ class Table(Fixed): values_axes : a list of the columns which comprise the data of this table data_columns : a list of the columns that we are allowing indexing - (these become single columns in values_axes), or True to force all - columns + (these become single columns in values_axes) nan_rep : the string to use for nan representations for string objects levels : the names of levels