Skip to content
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
5 changes: 5 additions & 0 deletions pandas-stubs/io/formats/style.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ from typing import (

from matplotlib.colors import Colormap
import numpy as np
from pandas import Index
from pandas.core.frame import DataFrame
from pandas.core.series import Series

Expand Down Expand Up @@ -52,6 +53,10 @@ class _DataFrameFunc(Protocol):
) -> npt.NDArray | DataFrame: ...

class Styler(StylerRenderer):
@property
def columns(self) -> Index[Any]: ...
@property
def index(self) -> Index[Any]: ...
def __init__(
self,
data: DataFrame | Series,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_styler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy.typing as npt
from pandas import (
DataFrame,
Index,
Series,
)
from pandas._testing import ensure_clean
Expand Down Expand Up @@ -224,3 +225,9 @@ def test_subset() -> None:
check(assert_type(DF.style.highlight_min(subset=IndexSlice[1:2]), Styler), Styler)
check(assert_type(DF.style.highlight_min(subset=[1]), Styler), Styler)
check(assert_type(DF.style.highlight_min(subset=DF.columns[1:]), Styler), Styler)


def test_styler_columns_and_index() -> None:
styler = DF.style
check(assert_type(styler.columns, Index), Index)
check(assert_type(styler.index, Index), Index)