Skip to content

Commit c93e803

Browse files
authored
DOC: Fixing EX01 - Added examples (pandas-dev#54354)
* Example for deregister * correcting deregister example
1 parent 7eb2546 commit c93e803

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
6464
MSG='Partially validate docstrings (EX01)' ; echo $MSG
6565
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
6666
pandas.io.stata.StataWriter.write_file \
67-
pandas.plotting.deregister_matplotlib_converters \
6867
pandas.api.extensions.ExtensionArray \
6968
RET=$(($RET + $?)) ; echo $MSG "DONE"
7069

pandas/plotting/_misc.py

+23
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,29 @@ def deregister() -> None:
124124
--------
125125
register_matplotlib_converters : Register pandas formatters and converters
126126
with matplotlib.
127+
128+
Examples
129+
--------
130+
.. plot::
131+
:context: close-figs
132+
133+
The following line is done automatically by pandas so
134+
the plot can be rendered:
135+
136+
>>> pd.plotting.register_matplotlib_converters()
137+
138+
>>> df = pd.DataFrame({'ts': pd.period_range('2020', periods=2, freq='M'),
139+
... 'y': [1, 2]
140+
... })
141+
>>> plot = df.plot.line(x='ts', y='y')
142+
143+
Unsetting the register manually an error will be raised:
144+
145+
>>> pd.set_option("plotting.matplotlib.register_converters",
146+
... False) # doctest: +SKIP
147+
>>> df.plot.line(x='ts', y='y') # doctest: +SKIP
148+
Traceback (most recent call last):
149+
TypeError: float() argument must be a string or a real number, not 'Period'
127150
"""
128151
plot_backend = _get_plot_backend("matplotlib")
129152
plot_backend.deregister()

0 commit comments

Comments
 (0)