Skip to content

Commit bcfc608

Browse files
D412: No blank lines allowed between a section header and its content (#31956)
1 parent e8eb49d commit bcfc608

31 files changed

+44
-89
lines changed

pandas/_config/config.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ class option_context:
395395
396396
Examples
397397
--------
398-
399398
>>> with option_context('display.max_rows', 10, 'display.max_columns', 5):
400399
... ...
401400
"""
@@ -716,8 +715,8 @@ def config_prefix(prefix):
716715
Warning: This is not thread - safe, and won't work properly if you import
717716
the API functions into your module using the "from x import y" construct.
718717
719-
Example:
720-
718+
Example
719+
-------
721720
import pandas._config.config as cf
722721
with cf.config_prefix("display.font"):
723722
cf.register_option("color", "red")

pandas/_testing.py

+31-29
Original file line numberDiff line numberDiff line change
@@ -1970,35 +1970,39 @@ def makeCustomDataframe(
19701970
r_idx_type=None,
19711971
):
19721972
"""
1973-
nrows, ncols - number of data rows/cols
1974-
c_idx_names, idx_names - False/True/list of strings, yields No names ,
1975-
default names or uses the provided names for the levels of the
1976-
corresponding index. You can provide a single string when
1977-
c_idx_nlevels ==1.
1978-
c_idx_nlevels - number of levels in columns index. > 1 will yield MultiIndex
1979-
r_idx_nlevels - number of levels in rows index. > 1 will yield MultiIndex
1980-
data_gen_f - a function f(row,col) which return the data value
1981-
at that position, the default generator used yields values of the form
1982-
"RxCy" based on position.
1983-
c_ndupe_l, r_ndupe_l - list of integers, determines the number
1984-
of duplicates for each label at a given level of the corresponding
1985-
index. The default `None` value produces a multiplicity of 1 across
1986-
all levels, i.e. a unique index. Will accept a partial list of length
1987-
N < idx_nlevels, for just the first N levels. If ndupe doesn't divide
1988-
nrows/ncol, the last label might have lower multiplicity.
1989-
dtype - passed to the DataFrame constructor as is, in case you wish to
1990-
have more control in conjunction with a custom `data_gen_f`
1991-
r_idx_type, c_idx_type - "i"/"f"/"s"/"u"/"dt"/"td".
1992-
If idx_type is not None, `idx_nlevels` must be 1.
1993-
"i"/"f" creates an integer/float index,
1994-
"s"/"u" creates a string/unicode index
1995-
"dt" create a datetime index.
1996-
"td" create a timedelta index.
1997-
1998-
if unspecified, string labels will be generated.
1973+
Create a DataFrame using supplied parameters.
19991974
2000-
Examples:
1975+
Parameters
1976+
----------
1977+
nrows, ncols - number of data rows/cols
1978+
c_idx_names, idx_names - False/True/list of strings, yields No names ,
1979+
default names or uses the provided names for the levels of the
1980+
corresponding index. You can provide a single string when
1981+
c_idx_nlevels ==1.
1982+
c_idx_nlevels - number of levels in columns index. > 1 will yield MultiIndex
1983+
r_idx_nlevels - number of levels in rows index. > 1 will yield MultiIndex
1984+
data_gen_f - a function f(row,col) which return the data value
1985+
at that position, the default generator used yields values of the form
1986+
"RxCy" based on position.
1987+
c_ndupe_l, r_ndupe_l - list of integers, determines the number
1988+
of duplicates for each label at a given level of the corresponding
1989+
index. The default `None` value produces a multiplicity of 1 across
1990+
all levels, i.e. a unique index. Will accept a partial list of length
1991+
N < idx_nlevels, for just the first N levels. If ndupe doesn't divide
1992+
nrows/ncol, the last label might have lower multiplicity.
1993+
dtype - passed to the DataFrame constructor as is, in case you wish to
1994+
have more control in conjunction with a custom `data_gen_f`
1995+
r_idx_type, c_idx_type - "i"/"f"/"s"/"u"/"dt"/"td".
1996+
If idx_type is not None, `idx_nlevels` must be 1.
1997+
"i"/"f" creates an integer/float index,
1998+
"s"/"u" creates a string/unicode index
1999+
"dt" create a datetime index.
2000+
"td" create a timedelta index.
2001+
2002+
if unspecified, string labels will be generated.
20012003
2004+
Examples
2005+
--------
20022006
# 5 row, 3 columns, default names on both, single index on both axis
20032007
>> makeCustomDataframe(5,3)
20042008
@@ -2514,7 +2518,6 @@ class RNGContext:
25142518
25152519
Examples
25162520
--------
2517-
25182521
with RNGContext(42):
25192522
np.random.randn()
25202523
"""
@@ -2669,7 +2672,6 @@ def set_timezone(tz: str):
26692672
26702673
Examples
26712674
--------
2672-
26732675
>>> from datetime import datetime
26742676
>>> from dateutil.tz import tzlocal
26752677
>>> tzlocal().tzname(datetime.now())

pandas/core/accessor.py

-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ def __init__(self, pandas_object): # noqa: E999
233233
234234
Examples
235235
--------
236-
237236
In your library code::
238237
239238
import pandas as pd

pandas/core/arrays/boolean.py

-2
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ def any(self, skipna: bool = True, **kwargs):
488488
489489
Examples
490490
--------
491-
492491
The result indicates whether any element is True (and by default
493492
skips NAs):
494493
@@ -557,7 +556,6 @@ def all(self, skipna: bool = True, **kwargs):
557556
558557
Examples
559558
--------
560-
561559
The result indicates whether any element is True (and by default
562560
skips NAs):
563561

pandas/core/arrays/categorical.py

-1
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,6 @@ def isin(self, values):
23882388
23892389
Examples
23902390
--------
2391-
23922391
>>> s = pd.Categorical(['lama', 'cow', 'lama', 'beetle', 'lama',
23932392
... 'hippo'])
23942393
>>> s.isin(['cow', 'lama'])

pandas/core/arrays/sparse/dtype.py

-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ def _subtype_with_str(self):
336336
337337
Returns
338338
-------
339-
340339
>>> SparseDtype(int, 1)._subtype_with_str
341340
dtype('int64')
342341

pandas/core/computation/pytables.py

-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ class PyTablesExpr(expr.Expr):
501501
502502
Examples
503503
--------
504-
505504
'index>=date'
506505
"columns=['A', 'D']"
507506
'columns=A'

pandas/core/dtypes/concat.py

-2
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,11 @@ def union_categoricals(
215215
216216
Notes
217217
-----
218-
219218
To learn more about categories, see `link
220219
<https://pandas.pydata.org/pandas-docs/stable/user_guide/categorical.html#unioning>`__
221220
222221
Examples
223222
--------
224-
225223
>>> from pandas.api.types import union_categoricals
226224
227225
If you want to combine categoricals that do not necessarily have

pandas/core/frame.py

-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,6 @@ def iterrows(self) -> Iterable[Tuple[Optional[Hashable], Series]]:
927927
928928
Notes
929929
-----
930-
931930
1. Because ``iterrows`` returns a Series for each row,
932931
it does **not** preserve dtypes across the rows (dtypes are
933932
preserved across columns for DataFrames). For example,

pandas/core/generic.py

-9
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,6 @@ def rename(
899899
900900
Examples
901901
--------
902-
903902
>>> s = pd.Series([1, 2, 3])
904903
>>> s
905904
0 1
@@ -2208,7 +2207,6 @@ def to_json(
22082207
22092208
Examples
22102209
--------
2211-
22122210
>>> df = pd.DataFrame([['a', 'b'], ['c', 'd']],
22132211
... index=['row 1', 'row 2'],
22142212
... columns=['col 1', 'col 2'])
@@ -2507,7 +2505,6 @@ def to_sql(
25072505
25082506
Examples
25092507
--------
2510-
25112508
Create an in-memory SQLite database.
25122509
25132510
>>> from sqlalchemy import create_engine
@@ -4185,7 +4182,6 @@ def reindex(self: FrameOrSeries, *args, **kwargs) -> FrameOrSeries:
41854182
41864183
Examples
41874184
--------
4188-
41894185
``DataFrame.reindex`` supports two calling conventions
41904186
41914187
* ``(index=index_labels, columns=column_labels, ...)``
@@ -5768,7 +5764,6 @@ def convert_dtypes(
57685764
57695765
Notes
57705766
-----
5771-
57725767
By default, ``convert_dtypes`` will attempt to convert a Series (or each
57735768
Series in a DataFrame) to dtypes that support ``pd.NA``. By using the options
57745769
``convert_string``, ``convert_integer``, and ``convert_boolean``, it is
@@ -7434,7 +7429,6 @@ def asfreq(
74347429
74357430
Examples
74367431
--------
7437-
74387432
Start by creating a series with 4 one minute timestamps.
74397433
74407434
>>> index = pd.date_range('1/1/2000', periods=4, freq='T')
@@ -7713,7 +7707,6 @@ def resample(
77137707
77147708
Examples
77157709
--------
7716-
77177710
Start by creating a series with 9 one minute timestamps.
77187711
77197712
>>> index = pd.date_range('1/1/2000', periods=9, freq='T')
@@ -8100,7 +8093,6 @@ def rank(
81008093
81018094
Examples
81028095
--------
8103-
81048096
>>> df = pd.DataFrame(data={'Animal': ['cat', 'penguin', 'dog',
81058097
... 'spider', 'snake'],
81068098
... 'Number_legs': [4, 2, 4, 8, np.nan]})
@@ -9235,7 +9227,6 @@ def tz_localize(
92359227
92369228
Examples
92379229
--------
9238-
92399230
Localize local times:
92409231
92419232
>>> s = pd.Series([1],

pandas/core/groupby/groupby.py

-2
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,6 @@ def ngroup(self, ascending: bool = True):
19951995
19961996
Examples
19971997
--------
1998-
19991998
>>> df = pd.DataFrame({"A": list("aaabba")})
20001999
>>> df
20012000
A
@@ -2062,7 +2061,6 @@ def cumcount(self, ascending: bool = True):
20622061
20632062
Examples
20642063
--------
2065-
20662064
>>> df = pd.DataFrame([['a'], ['a'], ['a'], ['b'], ['b'], ['a']],
20672065
... columns=['A'])
20682066
>>> df

pandas/core/groupby/grouper.py

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class Grouper:
7777
7878
Examples
7979
--------
80-
8180
Syntactic sugar for ``df.groupby('A')``
8281
8382
>>> df.groupby(Grouper(key='A'))

pandas/core/indexes/base.py

-4
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,6 @@ def _get_level_values(self, level):
14521452
14531453
Examples
14541454
--------
1455-
14561455
>>> idx = pd.Index(list('abc'))
14571456
>>> idx
14581457
Index(['a', 'b', 'c'], dtype='object')
@@ -2501,7 +2500,6 @@ def union(self, other, sort=None):
25012500
25022501
Examples
25032502
--------
2504-
25052503
Union matching dtypes
25062504
25072505
>>> idx1 = pd.Index([1, 2, 3, 4])
@@ -2632,7 +2630,6 @@ def intersection(self, other, sort=False):
26322630
26332631
Examples
26342632
--------
2635-
26362633
>>> idx1 = pd.Index([1, 2, 3, 4])
26372634
>>> idx2 = pd.Index([3, 4, 5, 6])
26382635
>>> idx1.intersection(idx2)
@@ -2713,7 +2710,6 @@ def difference(self, other, sort=None):
27132710
27142711
Examples
27152712
--------
2716-
27172713
>>> idx1 = pd.Index([2, 1, 3, 4])
27182714
>>> idx2 = pd.Index([3, 4, 5, 6])
27192715
>>> idx1.difference(idx2)

pandas/core/indexes/multi.py

-2
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,6 @@ def get_level_values(self, level):
15491549
15501550
Examples
15511551
--------
1552-
15531552
Create a MultiIndex:
15541553
15551554
>>> mi = pd.MultiIndex.from_arrays((list('abc'), list('def')))
@@ -1713,7 +1712,6 @@ def _sort_levels_monotonic(self):
17131712
17141713
Examples
17151714
--------
1716-
17171715
>>> mi = pd.MultiIndex(levels=[['a', 'b'], ['bb', 'aa']],
17181716
... codes=[[0, 0, 1, 1], [0, 1, 0, 1]])
17191717
>>> mi

pandas/core/indexes/period.py

-1
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ def period_range(
788788
789789
Examples
790790
--------
791-
792791
>>> pd.period_range(start='2017-01-01', end='2018-01-01', freq='M')
793792
PeriodIndex(['2017-01', '2017-02', '2017-03', '2017-04', '2017-05',
794793
'2017-06', '2017-06', '2017-07', '2017-08', '2017-09',

pandas/core/indexes/timedeltas.py

-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ def timedelta_range(
321321
322322
Examples
323323
--------
324-
325324
>>> pd.timedelta_range(start='1 day', periods=4)
326325
TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'],
327326
dtype='timedelta64[ns]', freq='D')

pandas/core/indexing.py

-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class _IndexSlice:
4848
4949
Examples
5050
--------
51-
5251
>>> midx = pd.MultiIndex.from_product([['A0','A1'], ['B0','B1','B2','B3']])
5352
>>> columns = ['foo', 'bar']
5453
>>> dfmi = pd.DataFrame(np.arange(16).reshape((len(midx), len(columns))),
@@ -124,7 +123,6 @@ def iloc(self) -> "_iLocIndexer":
124123
125124
Examples
126125
--------
127-
128126
>>> mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4},
129127
... {'a': 100, 'b': 200, 'c': 300, 'd': 400},
130128
... {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }]

pandas/core/resample.py

-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ def backfill(self, limit=None):
550550
551551
Examples
552552
--------
553-
554553
Resampling a Series:
555554
556555
>>> s = pd.Series([1, 2, 3],

pandas/core/strings.py

-3
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True):
349349
350350
Examples
351351
--------
352-
353352
Returning a Series of booleans using only a literal pattern.
354353
355354
>>> s1 = pd.Series(['Mouse', 'dog', 'house and parrot', '23', np.NaN])
@@ -1274,7 +1273,6 @@ def str_findall(arr, pat, flags=0):
12741273
12751274
Examples
12761275
--------
1277-
12781276
>>> s = pd.Series(['Lion', 'Monkey', 'Rabbit'])
12791277
12801278
The search for the pattern 'Monkey' returns one match:
@@ -1743,7 +1741,6 @@ def str_wrap(arr, width, **kwargs):
17431741
17441742
Examples
17451743
--------
1746-
17471744
>>> s = pd.Series(['line to be wrapped', 'another line to be wrapped'])
17481745
>>> s.str.wrap(12)
17491746
0 line to be\nwrapped

pandas/core/tools/timedeltas.py

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def to_timedelta(arg, unit="ns", errors="raise"):
5353
5454
Examples
5555
--------
56-
5756
Parsing a single string to a Timedelta:
5857
5958
>>> pd.to_timedelta('1 days 06:05:01.00003')

pandas/core/window/ewm.py

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ class EWM(_Rolling):
9898
9999
Examples
100100
--------
101-
102101
>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
103102
>>> df
104103
B

0 commit comments

Comments
 (0)