Skip to content

TYP: DataFrame.to_gbq, DataFrame.to_html (easy: copy-paste from format module) #38461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pandas/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
]
51 changes: 27 additions & 24 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@
ArrayLike,
Axes,
Axis,
ColspaceArgType,
CompressionOptions,
Dtype,
FilePathOrBuffer,
FloatFormatType,
FormattersType,
FrameOrSeriesUnion,
IndexKeyFunc,
Label,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 3 additions & 8 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
----------
Expand Down