Skip to content

DOC: Set value for undefined variables in examples #51389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ def relabel_result(
>>> funcs = {"A": ["max"], "C": ["max"], "B": ["mean", "min"]}
>>> columns = ("foo", "aab", "bar", "dat")
>>> order = [0, 1, 2, 3]
>>> _relabel_result(result, func, columns, order) # doctest: +SKIP
>>> relabel_result(result, funcs, columns, order) # doctest: +SKIP
dict(A=Series([2.0, NaN, NaN, NaN], index=["foo", "aab", "bar", "dat"]),
C=Series([NaN, 6.0, NaN, NaN], index=["foo", "aab", "bar", "dat"]),
B=Series([NaN, NaN, 2.5, 4.0], index=["foo", "aab", "bar", "dat"]))
Expand Down
1 change: 1 addition & 0 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def construct_from_string(
For extension dtypes with arguments the following may be an
adequate implementation.

>>> import re
>>> @classmethod
... def construct_from_string(cls, string):
... pattern = re.compile(r"^my_type\[(?P<arg_name>.+)\]$")
Expand Down
11 changes: 10 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ def to_excel(

>>> with pd.ExcelWriter('output.xlsx',
... mode='a') as writer: # doctest: +SKIP
... df.to_excel(writer, sheet_name='Sheet_name_3')
... df1.to_excel(writer, sheet_name='Sheet_name_3')

To set the library that is used to write the Excel file,
you can pass the `engine` keyword (the default engine is
Expand Down Expand Up @@ -5894,6 +5894,15 @@ def pipe(
Use ``.pipe`` when chaining together functions that expect
Series, DataFrames or GroupBy objects. Instead of writing

>>> df = pd.Dataframe(np.random.rand(2, 2))
>>> h = lambda df: [x.lower() for x in df.columns]
>>> def g(x, arg1):
... return x * arg1
>>> def func(x, arg2, arg3):
... return x * arg2 * arg3
>>> a = 1
>>> b = 2
>>> c = 3
>>> func(g(h(df), arg1=a), arg2=b, arg3=c) # doctest: +SKIP

You can write
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,7 @@ def apply_index(

>>> df = pd.DataFrame([[1,2], [3,4]], index=["A", "B"])
>>> def color_b(s):
... return {ret}
... return '{ret}'
>>> df.style.{this}_index(color_b) # doctest: +SKIP

.. figure:: ../../_static/style/appmaphead1.png
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/style_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ def format_index(

>>> df = pd.DataFrame([[1, 2, 3]],
... columns=pd.MultiIndex.from_arrays([["a", "a", "b"],[2, np.nan, 4]]))
>>> df.style.format_index({0: lambda v: upper(v)}, axis=1, precision=1)
>>> df.style.format_index({0: lambda v: v.upper()}, axis=1, precision=1)
... # doctest: +SKIP
A B
2.0 nan 4.0
Expand Down