Skip to content

CLN: D412: No blank lines allowed between a section header and its content #31956

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
Show file tree
Hide file tree
Changes from all 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: 2 additions & 3 deletions pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ class option_context:

Examples
--------

>>> with option_context('display.max_rows', 10, 'display.max_columns', 5):
... ...
"""
Expand Down Expand Up @@ -716,8 +715,8 @@ def config_prefix(prefix):
Warning: This is not thread - safe, and won't work properly if you import
the API functions into your module using the "from x import y" construct.

Example:

Example
-------
import pandas._config.config as cf
with cf.config_prefix("display.font"):
cf.register_option("color", "red")
Expand Down
60 changes: 31 additions & 29 deletions pandas/_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,35 +1970,39 @@ def makeCustomDataframe(
r_idx_type=None,
):
"""
nrows, ncols - number of data rows/cols
c_idx_names, idx_names - False/True/list of strings, yields No names ,
default names or uses the provided names for the levels of the
corresponding index. You can provide a single string when
c_idx_nlevels ==1.
c_idx_nlevels - number of levels in columns index. > 1 will yield MultiIndex
r_idx_nlevels - number of levels in rows index. > 1 will yield MultiIndex
data_gen_f - a function f(row,col) which return the data value
at that position, the default generator used yields values of the form
"RxCy" based on position.
c_ndupe_l, r_ndupe_l - list of integers, determines the number
of duplicates for each label at a given level of the corresponding
index. The default `None` value produces a multiplicity of 1 across
all levels, i.e. a unique index. Will accept a partial list of length
N < idx_nlevels, for just the first N levels. If ndupe doesn't divide
nrows/ncol, the last label might have lower multiplicity.
dtype - passed to the DataFrame constructor as is, in case you wish to
have more control in conjunction with a custom `data_gen_f`
r_idx_type, c_idx_type - "i"/"f"/"s"/"u"/"dt"/"td".
If idx_type is not None, `idx_nlevels` must be 1.
"i"/"f" creates an integer/float index,
"s"/"u" creates a string/unicode index
"dt" create a datetime index.
"td" create a timedelta index.

if unspecified, string labels will be generated.
Create a DataFrame using supplied parameters.

Examples:
Parameters
----------
nrows, ncols - number of data rows/cols
c_idx_names, idx_names - False/True/list of strings, yields No names ,
default names or uses the provided names for the levels of the
corresponding index. You can provide a single string when
c_idx_nlevels ==1.
c_idx_nlevels - number of levels in columns index. > 1 will yield MultiIndex
r_idx_nlevels - number of levels in rows index. > 1 will yield MultiIndex
data_gen_f - a function f(row,col) which return the data value
at that position, the default generator used yields values of the form
"RxCy" based on position.
c_ndupe_l, r_ndupe_l - list of integers, determines the number
of duplicates for each label at a given level of the corresponding
index. The default `None` value produces a multiplicity of 1 across
all levels, i.e. a unique index. Will accept a partial list of length
N < idx_nlevels, for just the first N levels. If ndupe doesn't divide
nrows/ncol, the last label might have lower multiplicity.
dtype - passed to the DataFrame constructor as is, in case you wish to
have more control in conjunction with a custom `data_gen_f`
r_idx_type, c_idx_type - "i"/"f"/"s"/"u"/"dt"/"td".
If idx_type is not None, `idx_nlevels` must be 1.
"i"/"f" creates an integer/float index,
"s"/"u" creates a string/unicode index
"dt" create a datetime index.
"td" create a timedelta index.

if unspecified, string labels will be generated.

Examples
--------
# 5 row, 3 columns, default names on both, single index on both axis
>> makeCustomDataframe(5,3)

Expand Down Expand Up @@ -2514,7 +2518,6 @@ class RNGContext:

Examples
--------

with RNGContext(42):
np.random.randn()
"""
Expand Down Expand Up @@ -2669,7 +2672,6 @@ def set_timezone(tz: str):

Examples
--------

>>> from datetime import datetime
>>> from dateutil.tz import tzlocal
>>> tzlocal().tzname(datetime.now())
Expand Down
1 change: 0 additions & 1 deletion pandas/core/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def __init__(self, pandas_object): # noqa: E999

Examples
--------

In your library code::

import pandas as pd
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/arrays/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ def any(self, skipna: bool = True, **kwargs):

Examples
--------

The result indicates whether any element is True (and by default
skips NAs):

Expand Down Expand Up @@ -557,7 +556,6 @@ def all(self, skipna: bool = True, **kwargs):

Examples
--------

The result indicates whether any element is True (and by default
skips NAs):

Expand Down
1 change: 0 additions & 1 deletion pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,6 @@ def isin(self, values):

Examples
--------

>>> s = pd.Categorical(['lama', 'cow', 'lama', 'beetle', 'lama',
... 'hippo'])
>>> s.isin(['cow', 'lama'])
Expand Down
1 change: 0 additions & 1 deletion pandas/core/arrays/sparse/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ def _subtype_with_str(self):

Returns
-------

>>> SparseDtype(int, 1)._subtype_with_str
dtype('int64')

Expand Down
1 change: 0 additions & 1 deletion pandas/core/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ class PyTablesExpr(expr.Expr):

Examples
--------

'index>=date'
"columns=['A', 'D']"
'columns=A'
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/dtypes/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,11 @@ def union_categoricals(

Notes
-----

To learn more about categories, see `link
<https://pandas.pydata.org/pandas-docs/stable/user_guide/categorical.html#unioning>`__

Examples
--------

>>> from pandas.api.types import union_categoricals

If you want to combine categoricals that do not necessarily have
Expand Down
1 change: 0 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,6 @@ def iterrows(self) -> Iterable[Tuple[Optional[Hashable], Series]]:

Notes
-----

1. Because ``iterrows`` returns a Series for each row,
it does **not** preserve dtypes across the rows (dtypes are
preserved across columns for DataFrames). For example,
Expand Down
9 changes: 0 additions & 9 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,6 @@ def rename(

Examples
--------

>>> s = pd.Series([1, 2, 3])
>>> s
0 1
Expand Down Expand Up @@ -2208,7 +2207,6 @@ def to_json(

Examples
--------

>>> df = pd.DataFrame([['a', 'b'], ['c', 'd']],
... index=['row 1', 'row 2'],
... columns=['col 1', 'col 2'])
Expand Down Expand Up @@ -2507,7 +2505,6 @@ def to_sql(

Examples
--------

Create an in-memory SQLite database.

>>> from sqlalchemy import create_engine
Expand Down Expand Up @@ -4185,7 +4182,6 @@ def reindex(self: FrameOrSeries, *args, **kwargs) -> FrameOrSeries:

Examples
--------

``DataFrame.reindex`` supports two calling conventions

* ``(index=index_labels, columns=column_labels, ...)``
Expand Down Expand Up @@ -5768,7 +5764,6 @@ def convert_dtypes(

Notes
-----

By default, ``convert_dtypes`` will attempt to convert a Series (or each
Series in a DataFrame) to dtypes that support ``pd.NA``. By using the options
``convert_string``, ``convert_integer``, and ``convert_boolean``, it is
Expand Down Expand Up @@ -7434,7 +7429,6 @@ def asfreq(

Examples
--------

Start by creating a series with 4 one minute timestamps.

>>> index = pd.date_range('1/1/2000', periods=4, freq='T')
Expand Down Expand Up @@ -7713,7 +7707,6 @@ def resample(

Examples
--------

Start by creating a series with 9 one minute timestamps.

>>> index = pd.date_range('1/1/2000', periods=9, freq='T')
Expand Down Expand Up @@ -8100,7 +8093,6 @@ def rank(

Examples
--------

>>> df = pd.DataFrame(data={'Animal': ['cat', 'penguin', 'dog',
... 'spider', 'snake'],
... 'Number_legs': [4, 2, 4, 8, np.nan]})
Expand Down Expand Up @@ -9235,7 +9227,6 @@ def tz_localize(

Examples
--------

Localize local times:

>>> s = pd.Series([1],
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1995,7 +1995,6 @@ def ngroup(self, ascending: bool = True):

Examples
--------

>>> df = pd.DataFrame({"A": list("aaabba")})
>>> df
A
Expand Down Expand Up @@ -2062,7 +2061,6 @@ def cumcount(self, ascending: bool = True):

Examples
--------

>>> df = pd.DataFrame([['a'], ['a'], ['a'], ['b'], ['b'], ['a']],
... columns=['A'])
>>> df
Expand Down
1 change: 0 additions & 1 deletion pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class Grouper:

Examples
--------

Syntactic sugar for ``df.groupby('A')``

>>> df.groupby(Grouper(key='A'))
Expand Down
4 changes: 0 additions & 4 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,6 @@ def _get_level_values(self, level):

Examples
--------

>>> idx = pd.Index(list('abc'))
>>> idx
Index(['a', 'b', 'c'], dtype='object')
Expand Down Expand Up @@ -2501,7 +2500,6 @@ def union(self, other, sort=None):

Examples
--------

Union matching dtypes

>>> idx1 = pd.Index([1, 2, 3, 4])
Expand Down Expand Up @@ -2632,7 +2630,6 @@ def intersection(self, other, sort=False):

Examples
--------

>>> idx1 = pd.Index([1, 2, 3, 4])
>>> idx2 = pd.Index([3, 4, 5, 6])
>>> idx1.intersection(idx2)
Expand Down Expand Up @@ -2713,7 +2710,6 @@ def difference(self, other, sort=None):

Examples
--------

>>> idx1 = pd.Index([2, 1, 3, 4])
>>> idx2 = pd.Index([3, 4, 5, 6])
>>> idx1.difference(idx2)
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,6 @@ def get_level_values(self, level):

Examples
--------

Create a MultiIndex:

>>> mi = pd.MultiIndex.from_arrays((list('abc'), list('def')))
Expand Down Expand Up @@ -1713,7 +1712,6 @@ def _sort_levels_monotonic(self):

Examples
--------

>>> mi = pd.MultiIndex(levels=[['a', 'b'], ['bb', 'aa']],
... codes=[[0, 0, 1, 1], [0, 1, 0, 1]])
>>> mi
Expand Down
1 change: 0 additions & 1 deletion pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ def period_range(

Examples
--------

>>> pd.period_range(start='2017-01-01', end='2018-01-01', freq='M')
PeriodIndex(['2017-01', '2017-02', '2017-03', '2017-04', '2017-05',
'2017-06', '2017-06', '2017-07', '2017-08', '2017-09',
Expand Down
1 change: 0 additions & 1 deletion pandas/core/indexes/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ def timedelta_range(

Examples
--------

>>> pd.timedelta_range(start='1 day', periods=4)
TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'],
dtype='timedelta64[ns]', freq='D')
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class _IndexSlice:

Examples
--------

>>> midx = pd.MultiIndex.from_product([['A0','A1'], ['B0','B1','B2','B3']])
>>> columns = ['foo', 'bar']
>>> dfmi = pd.DataFrame(np.arange(16).reshape((len(midx), len(columns))),
Expand Down Expand Up @@ -124,7 +123,6 @@ def iloc(self) -> "_iLocIndexer":

Examples
--------

>>> mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4},
... {'a': 100, 'b': 200, 'c': 300, 'd': 400},
... {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }]
Expand Down
1 change: 0 additions & 1 deletion pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ def backfill(self, limit=None):

Examples
--------

Resampling a Series:

>>> s = pd.Series([1, 2, 3],
Expand Down
3 changes: 0 additions & 3 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True):

Examples
--------

Returning a Series of booleans using only a literal pattern.

>>> s1 = pd.Series(['Mouse', 'dog', 'house and parrot', '23', np.NaN])
Expand Down Expand Up @@ -1274,7 +1273,6 @@ def str_findall(arr, pat, flags=0):

Examples
--------

>>> s = pd.Series(['Lion', 'Monkey', 'Rabbit'])

The search for the pattern 'Monkey' returns one match:
Expand Down Expand Up @@ -1743,7 +1741,6 @@ def str_wrap(arr, width, **kwargs):

Examples
--------

>>> s = pd.Series(['line to be wrapped', 'another line to be wrapped'])
>>> s.str.wrap(12)
0 line to be\nwrapped
Expand Down
1 change: 0 additions & 1 deletion pandas/core/tools/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def to_timedelta(arg, unit="ns", errors="raise"):

Examples
--------

Parsing a single string to a Timedelta:

>>> pd.to_timedelta('1 days 06:05:01.00003')
Expand Down
1 change: 0 additions & 1 deletion pandas/core/window/ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class EWM(_Rolling):

Examples
--------

>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
>>> df
B
Expand Down
Loading