diff --git a/pandas/_typing.py b/pandas/_typing.py index 09c490e64957d..924fc323584b0 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -146,5 +146,12 @@ CompressionOptions = Optional[Union[str, CompressionDict]] -# type of float formatter in DataFrameFormatter +# types in DataFrameFormatter +FormattersType = Union[ + List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable] +] +ColspaceType = Mapping[Label, Union[str, int]] FloatFormatType = Union[str, Callable, "EngFormatter"] +ColspaceArgType = Union[ + str, int, Sequence[Union[str, int]], Mapping[Label, Union[str, int]] +] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 0dff1305357b2..d698edbb0b8ad 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -51,9 +51,12 @@ ArrayLike, Axes, Axis, + ColspaceArgType, CompressionOptions, Dtype, FilePathOrBuffer, + FloatFormatType, + FormattersType, FrameOrSeriesUnion, IndexKeyFunc, Label, @@ -1612,11 +1615,11 @@ def to_gbq( self, destination_table: str, project_id: Optional[str] = None, - chunksize=None, + chunksize: Optional[int] = None, reauth: bool = False, if_exists: str = "fail", auth_local_webserver: bool = False, - table_schema=None, + table_schema: Optional[List[Dict[str, str]]] = None, location: Optional[str] = None, progress_bar: bool = True, credentials=None, @@ -2474,29 +2477,29 @@ def to_parquet( @Substitution(shared_params=fmt.common_docstring, returns=fmt.return_docstring) def to_html( self, - buf=None, - columns=None, - col_space=None, - header=True, - index=True, - na_rep="NaN", - formatters=None, - float_format=None, - sparsify=None, - index_names=True, - justify=None, - max_rows=None, - max_cols=None, - show_dimensions=False, + buf: Optional[FilePathOrBuffer[str]] = None, + columns: Optional[Sequence[str]] = None, + col_space: Optional[ColspaceArgType] = None, + header: Union[bool, Sequence[str]] = True, + index: bool = True, + na_rep: str = "NaN", + formatters: Optional[FormattersType] = None, + float_format: Optional[FloatFormatType] = None, + sparsify: Optional[bool] = None, + index_names: bool = True, + justify: Optional[str] = None, + max_rows: Optional[int] = None, + max_cols: Optional[int] = None, + show_dimensions: Union[bool, str] = False, decimal: str = ".", - bold_rows=True, - classes=None, - escape=True, - notebook=False, - border=None, - table_id=None, - render_links=False, - encoding=None, + bold_rows: bool = True, + classes: Optional[Union[str, List, Tuple]] = None, + escape: bool = True, + notebook: bool = False, + border: Optional[int] = None, + table_id: Optional[str] = None, + render_links: bool = False, + encoding: Optional[str] = None, ): """ Render a DataFrame as an HTML table. diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py index db34b882a3c35..527ee51873631 100644 --- a/pandas/io/formats/format.py +++ b/pandas/io/formats/format.py @@ -39,9 +39,12 @@ from pandas._libs.tslibs.nattype import NaTType from pandas._typing import ( ArrayLike, + ColspaceArgType, + ColspaceType, CompressionOptions, FilePathOrBuffer, FloatFormatType, + FormattersType, IndexLabel, Label, StorageOptions, @@ -81,14 +84,6 @@ from pandas import Categorical, DataFrame, Series -FormattersType = Union[ - List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable] -] -ColspaceType = Mapping[Label, Union[str, int]] -ColspaceArgType = Union[ - str, int, Sequence[Union[str, int]], Mapping[Label, Union[str, int]] -] - common_docstring = """ Parameters ----------