Skip to content

Commit b76f954

Browse files
authored
TYP: DataFrame.to_gbq, DataFrame.to_html (easy: copy-paste from format module) (#38461)
1 parent e4892f3 commit b76f954

File tree

3 files changed

+38
-33
lines changed

3 files changed

+38
-33
lines changed

pandas/_typing.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,12 @@
146146
CompressionOptions = Optional[Union[str, CompressionDict]]
147147

148148

149-
# type of float formatter in DataFrameFormatter
149+
# types in DataFrameFormatter
150+
FormattersType = Union[
151+
List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable]
152+
]
153+
ColspaceType = Mapping[Label, Union[str, int]]
150154
FloatFormatType = Union[str, Callable, "EngFormatter"]
155+
ColspaceArgType = Union[
156+
str, int, Sequence[Union[str, int]], Mapping[Label, Union[str, int]]
157+
]

pandas/core/frame.py

+27-24
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@
5151
ArrayLike,
5252
Axes,
5353
Axis,
54+
ColspaceArgType,
5455
CompressionOptions,
5556
Dtype,
5657
FilePathOrBuffer,
58+
FloatFormatType,
59+
FormattersType,
5760
FrameOrSeriesUnion,
5861
IndexKeyFunc,
5962
Label,
@@ -1612,11 +1615,11 @@ def to_gbq(
16121615
self,
16131616
destination_table: str,
16141617
project_id: Optional[str] = None,
1615-
chunksize=None,
1618+
chunksize: Optional[int] = None,
16161619
reauth: bool = False,
16171620
if_exists: str = "fail",
16181621
auth_local_webserver: bool = False,
1619-
table_schema=None,
1622+
table_schema: Optional[List[Dict[str, str]]] = None,
16201623
location: Optional[str] = None,
16211624
progress_bar: bool = True,
16221625
credentials=None,
@@ -2474,29 +2477,29 @@ def to_parquet(
24742477
@Substitution(shared_params=fmt.common_docstring, returns=fmt.return_docstring)
24752478
def to_html(
24762479
self,
2477-
buf=None,
2478-
columns=None,
2479-
col_space=None,
2480-
header=True,
2481-
index=True,
2482-
na_rep="NaN",
2483-
formatters=None,
2484-
float_format=None,
2485-
sparsify=None,
2486-
index_names=True,
2487-
justify=None,
2488-
max_rows=None,
2489-
max_cols=None,
2490-
show_dimensions=False,
2480+
buf: Optional[FilePathOrBuffer[str]] = None,
2481+
columns: Optional[Sequence[str]] = None,
2482+
col_space: Optional[ColspaceArgType] = None,
2483+
header: Union[bool, Sequence[str]] = True,
2484+
index: bool = True,
2485+
na_rep: str = "NaN",
2486+
formatters: Optional[FormattersType] = None,
2487+
float_format: Optional[FloatFormatType] = None,
2488+
sparsify: Optional[bool] = None,
2489+
index_names: bool = True,
2490+
justify: Optional[str] = None,
2491+
max_rows: Optional[int] = None,
2492+
max_cols: Optional[int] = None,
2493+
show_dimensions: Union[bool, str] = False,
24912494
decimal: str = ".",
2492-
bold_rows=True,
2493-
classes=None,
2494-
escape=True,
2495-
notebook=False,
2496-
border=None,
2497-
table_id=None,
2498-
render_links=False,
2499-
encoding=None,
2495+
bold_rows: bool = True,
2496+
classes: Optional[Union[str, List, Tuple]] = None,
2497+
escape: bool = True,
2498+
notebook: bool = False,
2499+
border: Optional[int] = None,
2500+
table_id: Optional[str] = None,
2501+
render_links: bool = False,
2502+
encoding: Optional[str] = None,
25002503
):
25012504
"""
25022505
Render a DataFrame as an HTML table.

pandas/io/formats/format.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@
3939
from pandas._libs.tslibs.nattype import NaTType
4040
from pandas._typing import (
4141
ArrayLike,
42+
ColspaceArgType,
43+
ColspaceType,
4244
CompressionOptions,
4345
FilePathOrBuffer,
4446
FloatFormatType,
47+
FormattersType,
4548
IndexLabel,
4649
Label,
4750
StorageOptions,
@@ -81,14 +84,6 @@
8184
from pandas import Categorical, DataFrame, Series
8285

8386

84-
FormattersType = Union[
85-
List[Callable], Tuple[Callable, ...], Mapping[Union[str, int], Callable]
86-
]
87-
ColspaceType = Mapping[Label, Union[str, int]]
88-
ColspaceArgType = Union[
89-
str, int, Sequence[Union[str, int]], Mapping[Label, Union[str, int]]
90-
]
91-
9287
common_docstring = """
9388
Parameters
9489
----------

0 commit comments

Comments
 (0)