diff --git a/ci/code_checks.sh b/ci/code_checks.sh index fd256f2ff7db0..79445ec7b936d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -112,8 +112,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.DatetimeIndex.snap \ pandas.api.indexers.BaseIndexer \ pandas.api.indexers.VariableOffsetWindowIndexer \ - pandas.io.formats.style.Styler \ - pandas.io.formats.style.Styler.from_custom_template \ pandas.io.formats.style.Styler.set_caption \ pandas.io.formats.style.Styler.set_sticky \ pandas.io.formats.style.Styler.set_uuid \ @@ -157,8 +155,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.api.extensions.ExtensionArray.ndim \ pandas.api.extensions.ExtensionArray.shape \ pandas.api.extensions.ExtensionArray.tolist \ - pandas.DataFrame.columns \ - pandas.DataFrame.ffill \ pandas.DataFrame.pad \ pandas.DataFrame.swapaxes \ pandas.DataFrame.plot \ diff --git a/pandas/core/frame.py b/pandas/core/frame.py index feae3bb517c22..3a2ad225ae495 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -11849,7 +11849,24 @@ def isin_(x): updated with the new labels, and the output shows the modified DataFrame. """, ) - columns = properties.AxisProperty(axis=0, doc="The column labels of the DataFrame.") + columns = properties.AxisProperty( + axis=0, + doc=dedent( + """ + The column labels of the DataFrame. + + Examples + -------- + >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) + >>> df + A B + 0 1 3 + 1 2 4 + >>> df.columns + Index(['A', 'B'], dtype='object') + """ + ), + ) # ---------------------------------------------------------------------- # Add plotting methods to DataFrame diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 9062721c73285..278527fa8fc85 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -241,6 +241,16 @@ class Styler(StylerRenderer): Any, or all, or these classes can be renamed by using the ``css_class_names`` argument in ``Styler.set_table_classes``, giving a value such as *{"row": "MY_ROW_CLASS", "col_trim": "", "row_trim": ""}*. + + Examples + -------- + >>> df = pd.DataFrame([[1.0, 2.0, 3.0], [4, 5, 6]], index=['a', 'b'], + ... columns=['A', 'B', 'C']) + >>> pd.io.formats.style.Styler(df, precision=2, + ... caption="My table") # doctest: +SKIP + + Please see: + `Table Visualization <../../user_guide/style.ipynb>`_ for more examples. """ def __init__( @@ -3492,6 +3502,19 @@ def from_custom_template( MyStyler : subclass of Styler Has the correct ``env``,``template_html``, ``template_html_table`` and ``template_html_style`` class attributes set. + + Examples + -------- + >>> from pandas.io.formats.style import Styler # doctest: +SKIP + >>> from IPython.display import HTML # doctest: +SKIP + >>> df = pd.DataFrame({"A": [1, 2]}) # doctest: +SKIP + >>> path = "path/to/template" # doctest: +SKIP + >>> file = "template.tpl" # doctest: +SKIP + >>> EasyStyler = Styler.from_custom_template(path, file) # doctest: +SKIP + >>> HTML(EasyStyler(df).to_html(table_title="Another Title")) # doctest: +SKIP + + Please see: + `Table Visualization <../../user_guide/style.ipynb>`_ for more examples. """ loader = jinja2.ChoiceLoader([jinja2.FileSystemLoader(searchpath), cls.loader])