Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -13,6 +13,7 @@ from matplotlib.colors import Colormap
import numpy as np
from pandas.core.frame import DataFrame
from pandas.core.series import Series
from pandas import Index

from pandas._typing import (
Axis,
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 @@ -14,6 +14,7 @@
from pandas import (
DataFrame,
Series,
Index
)
from pandas._testing import ensure_clean
import pytest
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)
Loading