Skip to content

Commit 9629b3a

Browse files
DOC: Fixing EX01 - Added examples (#54039)
* Examples Styler, from_custom_template, DataFrame.columns * Edit link * Fixing links * Link again * Trying that link again --------- Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent 4b27e94 commit 9629b3a

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

ci/code_checks.sh

-4
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
112112
pandas.DatetimeIndex.snap \
113113
pandas.api.indexers.BaseIndexer \
114114
pandas.api.indexers.VariableOffsetWindowIndexer \
115-
pandas.io.formats.style.Styler \
116-
pandas.io.formats.style.Styler.from_custom_template \
117115
pandas.io.formats.style.Styler.set_caption \
118116
pandas.io.formats.style.Styler.set_sticky \
119117
pandas.io.formats.style.Styler.set_uuid \
@@ -157,8 +155,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
157155
pandas.api.extensions.ExtensionArray.ndim \
158156
pandas.api.extensions.ExtensionArray.shape \
159157
pandas.api.extensions.ExtensionArray.tolist \
160-
pandas.DataFrame.columns \
161-
pandas.DataFrame.ffill \
162158
pandas.DataFrame.pad \
163159
pandas.DataFrame.swapaxes \
164160
pandas.DataFrame.plot \

pandas/core/frame.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -11849,7 +11849,24 @@ def isin_(x):
1184911849
updated with the new labels, and the output shows the modified DataFrame.
1185011850
""",
1185111851
)
11852-
columns = properties.AxisProperty(axis=0, doc="The column labels of the DataFrame.")
11852+
columns = properties.AxisProperty(
11853+
axis=0,
11854+
doc=dedent(
11855+
"""
11856+
The column labels of the DataFrame.
11857+
11858+
Examples
11859+
--------
11860+
>>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
11861+
>>> df
11862+
A B
11863+
0 1 3
11864+
1 2 4
11865+
>>> df.columns
11866+
Index(['A', 'B'], dtype='object')
11867+
"""
11868+
),
11869+
)
1185311870

1185411871
# ----------------------------------------------------------------------
1185511872
# Add plotting methods to DataFrame

pandas/io/formats/style.py

+23
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ class Styler(StylerRenderer):
241241
Any, or all, or these classes can be renamed by using the ``css_class_names``
242242
argument in ``Styler.set_table_classes``, giving a value such as
243243
*{"row": "MY_ROW_CLASS", "col_trim": "", "row_trim": ""}*.
244+
245+
Examples
246+
--------
247+
>>> df = pd.DataFrame([[1.0, 2.0, 3.0], [4, 5, 6]], index=['a', 'b'],
248+
... columns=['A', 'B', 'C'])
249+
>>> pd.io.formats.style.Styler(df, precision=2,
250+
... caption="My table") # doctest: +SKIP
251+
252+
Please see:
253+
`Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
244254
"""
245255

246256
def __init__(
@@ -3492,6 +3502,19 @@ def from_custom_template(
34923502
MyStyler : subclass of Styler
34933503
Has the correct ``env``,``template_html``, ``template_html_table`` and
34943504
``template_html_style`` class attributes set.
3505+
3506+
Examples
3507+
--------
3508+
>>> from pandas.io.formats.style import Styler # doctest: +SKIP
3509+
>>> from IPython.display import HTML # doctest: +SKIP
3510+
>>> df = pd.DataFrame({"A": [1, 2]}) # doctest: +SKIP
3511+
>>> path = "path/to/template" # doctest: +SKIP
3512+
>>> file = "template.tpl" # doctest: +SKIP
3513+
>>> EasyStyler = Styler.from_custom_template(path, file) # doctest: +SKIP
3514+
>>> HTML(EasyStyler(df).to_html(table_title="Another Title")) # doctest: +SKIP
3515+
3516+
Please see:
3517+
`Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
34953518
"""
34963519
loader = jinja2.ChoiceLoader([jinja2.FileSystemLoader(searchpath), cls.loader])
34973520

0 commit comments

Comments
 (0)