Skip to content

Commit f4b4ec2

Browse files
jbrockmendeljorisvandenbossche
authored andcommitted
DOC/CLN: docstring cleanups (#27942)
1 parent 802f670 commit f4b4ec2

File tree

4 files changed

+63
-63
lines changed

4 files changed

+63
-63
lines changed

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ def to_numpy(self, dtype=None, copy=False):
11901190
Parameters
11911191
----------
11921192
dtype : str or numpy.dtype, optional
1193-
The dtype to pass to :meth:`numpy.asarray`
1193+
The dtype to pass to :meth:`numpy.asarray`.
11941194
copy : bool, default False
11951195
Whether to ensure that the returned value is a not a view on
11961196
another array. Note that ``copy=False`` does not *ensure* that

pandas/core/generic.py

+46-46
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class NDFrame(PandasObject, SelectionMixin):
131131
----------
132132
data : BlockManager
133133
axes : list
134-
copy : boolean, default False
134+
copy : bool, default False
135135
"""
136136

137137
_internal_names = [
@@ -280,16 +280,17 @@ def _setup_axes(
280280
ns=None,
281281
docs=None,
282282
):
283-
"""Provide axes setup for the major PandasObjects.
283+
"""
284+
Provide axes setup for the major PandasObjects.
284285
285286
Parameters
286287
----------
287288
axes : the names of the axes in order (lowest to highest)
288289
info_axis_num : the axis of the selector dimension (int)
289290
stat_axis_num : the number of axis for the default stats (int)
290291
aliases : other names for a single axis (dict)
291-
axes_are_reversed : boolean whether to treat passed axes as
292-
reversed (DataFrame)
292+
axes_are_reversed : bool
293+
Whether to treat passed axes as reversed (DataFrame).
293294
build_axes : setup the axis properties (default True)
294295
"""
295296

@@ -676,7 +677,7 @@ def transpose(self, *args, **kwargs):
676677
Parameters
677678
----------
678679
args : %(args_transpose)s
679-
copy : boolean, default False
680+
copy : bool, default False
680681
Make a copy of the underlying data. Mixed-dtype data will
681682
always result in a copy
682683
**kwargs
@@ -2257,10 +2258,10 @@ def to_json(
22572258
22582259
Parameters
22592260
----------
2260-
path_or_buf : string or file handle, optional
2261+
path_or_buf : str or file handle, optional
22612262
File path or object. If not specified, the result is returned as
22622263
a string.
2263-
orient : string
2264+
orient : str
22642265
Indication of expected JSON string format.
22652266
22662267
* Series
@@ -2539,7 +2540,7 @@ def to_msgpack(self, path_or_buf=None, encoding="utf-8", **kwargs):
25392540

25402541
def to_sql(
25412542
self,
2542-
name,
2543+
name: str,
25432544
con,
25442545
schema=None,
25452546
if_exists="fail",
@@ -2557,12 +2558,12 @@ def to_sql(
25572558
25582559
Parameters
25592560
----------
2560-
name : string
2561+
name : str
25612562
Name of SQL table.
25622563
con : sqlalchemy.engine.Engine or sqlite3.Connection
25632564
Using SQLAlchemy makes it possible to use any DB supported by that
25642565
library. Legacy support is provided for sqlite3.Connection objects.
2565-
schema : string, optional
2566+
schema : str, optional
25662567
Specify the schema (if database flavor supports this). If None, use
25672568
default schema.
25682569
if_exists : {'fail', 'replace', 'append'}, default 'fail'
@@ -2575,7 +2576,7 @@ def to_sql(
25752576
index : bool, default True
25762577
Write DataFrame index as a column. Uses `index_label` as the column
25772578
name in the table.
2578-
index_label : string or sequence, default None
2579+
index_label : str or sequence, default None
25792580
Column label for index column(s). If None is given (default) and
25802581
`index` is True, then the index names are used.
25812582
A sequence should be given if the DataFrame uses MultiIndex.
@@ -3251,11 +3252,10 @@ def _maybe_update_cacher(self, clear=False, verify_is_copy=True):
32513252
32523253
Parameters
32533254
----------
3254-
clear : boolean, default False
3255-
clear the item cache
3256-
verify_is_copy : boolean, default True
3257-
provide is_copy checks
3258-
3255+
clear : bool, default False
3256+
Clear the item cache.
3257+
verify_is_copy : bool, default True
3258+
Provide is_copy checks.
32593259
"""
32603260

32613261
cacher = getattr(self, "_cacher", None)
@@ -3621,11 +3621,11 @@ def _check_setitem_copy(self, stacklevel=4, t="setting", force=False):
36213621
36223622
Parameters
36233623
----------
3624-
stacklevel : integer, default 4
3624+
stacklevel : int, default 4
36253625
the level to show of the stack when the error is output
3626-
t : string, the type of setting error
3627-
force : boolean, default False
3628-
if True, then force showing an error
3626+
t : str, the type of setting error
3627+
force : bool, default False
3628+
If True, then force showing an error.
36293629
36303630
validate if we are doing a setitem on a chained copy.
36313631
@@ -3954,9 +3954,8 @@ def _update_inplace(self, result, verify_is_copy=True):
39543954
39553955
Parameters
39563956
----------
3957-
verify_is_copy : boolean, default True
3958-
provide is_copy checks
3959-
3957+
verify_is_copy : bool, default True
3958+
Provide is_copy checks.
39603959
"""
39613960
# NOTE: This does *not* call __finalize__ and that's an explicit
39623961
# decision that we may revisit in the future.
@@ -4571,9 +4570,9 @@ def filter(self, items=None, like=None, regex=None, axis=None):
45714570
----------
45724571
items : list-like
45734572
Keep labels from axis which are in items.
4574-
like : string
4573+
like : str
45754574
Keep labels from axis for which "like in label == True".
4576-
regex : string (regular expression)
4575+
regex : str (regular expression)
45774576
Keep labels from axis for which re.search(regex, label) == True.
45784577
axis : int or string axis name
45794578
The axis to filter on. By default this is the info axis,
@@ -5233,8 +5232,8 @@ def _consolidate(self, inplace=False):
52335232
52345233
Parameters
52355234
----------
5236-
inplace : boolean, default False
5237-
If False return new object, otherwise modify existing object
5235+
inplace : bool, default False
5236+
If False return new object, otherwise modify existing object.
52385237
52395238
Returns
52405239
-------
@@ -5680,11 +5679,12 @@ def as_blocks(self, copy=True):
56805679
56815680
Parameters
56825681
----------
5683-
copy : boolean, default True
5682+
copy : bool, default True
56845683
56855684
Returns
56865685
-------
5687-
values : a dict of dtype -> Constructor Types
5686+
dict
5687+
Mapping dtype -> Constructor Types.
56885688
"""
56895689
warnings.warn(
56905690
"as_blocks is deprecated and will be removed in a future version",
@@ -5993,17 +5993,17 @@ def _convert(
59935993
59945994
Parameters
59955995
----------
5996-
datetime : boolean, default False
5996+
datetime : bool, default False
59975997
If True, convert to date where possible.
5998-
numeric : boolean, default False
5998+
numeric : bool, default False
59995999
If True, attempt to convert to numbers (including strings), with
60006000
unconvertible values becoming NaN.
6001-
timedelta : boolean, default False
6001+
timedelta : bool, default False
60026002
If True, convert to timedelta where possible.
6003-
coerce : boolean, default False
6003+
coerce : bool, default False
60046004
If True, force conversion with unconvertible values converted to
6005-
nulls (NaN or NaT)
6006-
copy : boolean, default True
6005+
nulls (NaN or NaT).
6006+
copy : bool, default True
60076007
If True, return a copy even if no copy is necessary (e.g. no
60086008
conversion was done). Note: This is meant for internal use, and
60096009
should not be confused with inplace.
@@ -7870,7 +7870,7 @@ def asfreq(self, freq, method=None, how=None, normalize=False, fill_value=None):
78707870
78717871
Parameters
78727872
----------
7873-
freq : DateOffset object, or string
7873+
freq : DateOffset or str
78747874
method : {'backfill'/'bfill', 'pad'/'ffill'}, default None
78757875
Method to use for filling holes in reindexed Series (note this
78767876
does not fill NaNs that already were present):
@@ -8671,7 +8671,7 @@ def ranker(data):
86718671
level : int or level name, default None
86728672
Broadcast across a level, matching Index values on the
86738673
passed MultiIndex level
8674-
copy : boolean, default True
8674+
copy : bool, default True
86758675
Always returns new objects. If copy=False and no reindexing is
86768676
required then original objects are returned.
86778677
fill_value : scalar, default np.NaN
@@ -9463,7 +9463,7 @@ def truncate(self, before=None, after=None, axis=None, copy=True):
94639463
Truncate all rows after this index value.
94649464
axis : {0 or 'index', 1 or 'columns'}, optional
94659465
Axis to truncate. Truncates the index (rows) by default.
9466-
copy : boolean, default is True,
9466+
copy : bool, default is True,
94679467
Return a copy of the truncated section.
94689468
94699469
Returns
@@ -9607,13 +9607,13 @@ def tz_convert(self, tz, axis=0, level=None, copy=True):
96079607
96089608
Parameters
96099609
----------
9610-
tz : string or pytz.timezone object
9610+
tz : str or tzinfo object
96119611
axis : the axis to convert
96129612
level : int, str, default None
9613-
If axis ia a MultiIndex, convert a specific level. Otherwise
9614-
must be None
9615-
copy : boolean, default True
9616-
Also make a copy of the underlying data
9613+
If axis is a MultiIndex, convert a specific level. Otherwise
9614+
must be None.
9615+
copy : bool, default True
9616+
Also make a copy of the underlying data.
96179617
96189618
Returns
96199619
-------
@@ -9667,12 +9667,12 @@ def tz_localize(
96679667
96689668
Parameters
96699669
----------
9670-
tz : string or pytz.timezone object
9670+
tz : str or tzinfo
96719671
axis : the axis to localize
96729672
level : int, str, default None
96739673
If axis ia a MultiIndex, localize a specific level. Otherwise
96749674
must be None
9675-
copy : boolean, default True
9675+
copy : bool, default True
96769676
Also make a copy of the underlying data
96779677
ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
96789678
When clocks moved backward due to DST, ambiguous times may arise.
@@ -11009,7 +11009,7 @@ def _doc_parms(cls):
1100911009
----------
1101011010
axis : {0 or 'index', 1 or 'columns'}, default 0
1101111011
The index or the name of the axis. 0 is equivalent to None or 'index'.
11012-
skipna : boolean, default True
11012+
skipna : bool, default True
1101311013
Exclude NA/null values. If an entire row/column is NA, the result
1101411014
will be NA.
1101511015
*args, **kwargs :

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,8 @@ def nonzero(self):
675675
3 4
676676
dtype: int64
677677
678-
>>> s = pd.Series([0, 3, 0, 4], index=['a', 'b', 'c', 'd'])
679678
# same return although index of s is different
679+
>>> s = pd.Series([0, 3, 0, 4], index=['a', 'b', 'c', 'd'])
680680
>>> s.nonzero()
681681
(array([1, 3]),)
682682
>>> s.iloc[s.nonzero()[0]]

pandas/plotting/_core.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def hist_series(
5353
rotation of y axis labels
5454
figsize : tuple, default None
5555
figure size in inches by default
56-
bins : integer or sequence, default 10
56+
bins : int or sequence, default 10
5757
Number of histogram bins to be used. If an integer is given, bins + 1
5858
bin edges are calculated and returned. If bins is a sequence, gives
5959
bin edges, including left edge of first bin and right edge of last
@@ -116,7 +116,7 @@ def hist_frame(
116116
----------
117117
data : DataFrame
118118
The pandas object holding the data.
119-
column : string or sequence
119+
column : str or sequence
120120
If passed, will be used to limit data to a subset of columns.
121121
by : object, optional
122122
If passed, then used to form histograms for separate groups.
@@ -148,7 +148,7 @@ def hist_frame(
148148
`matplotlib.rcParams` by default.
149149
layout : tuple, optional
150150
Tuple of (rows, columns) for the layout of the histograms.
151-
bins : integer or sequence, default 10
151+
bins : int or sequence, default 10
152152
Number of histogram bins to be used. If an integer is given, bins + 1
153153
bin edges are calculated and returned. If bins is a sequence, gives
154154
bin edges, including left edge of first bin and right edge of last
@@ -177,7 +177,7 @@ def hist_frame(
177177
>>> df = pd.DataFrame({
178178
... 'length': [1.5, 0.5, 1.2, 0.9, 3],
179179
... 'width': [0.7, 0.2, 0.15, 0.2, 1.1]
180-
... }, index= ['pig', 'rabbit', 'duck', 'chicken', 'horse'])
180+
... }, index=['pig', 'rabbit', 'duck', 'chicken', 'horse'])
181181
>>> hist = df.hist(bins=3)
182182
"""
183183
plot_backend = _get_plot_backend()
@@ -370,8 +370,8 @@ def boxplot(
370370
If ``return_type`` is `None`, a NumPy array of axes with the same shape
371371
as ``layout`` is returned:
372372
373-
>>> boxplot = df.boxplot(column=['Col1', 'Col2'], by='X',
374-
... return_type=None)
373+
>>> boxplot = df.boxplot(column=['Col1', 'Col2'], by='X',
374+
... return_type=None)
375375
>>> type(boxplot)
376376
<class 'numpy.ndarray'>
377377
"""
@@ -446,7 +446,7 @@ def boxplot_frame_groupby(
446446
* ``True`` - create a subplot for each group
447447
column : column name or list of names, or vector
448448
Can be any valid input to groupby
449-
fontsize : int or string
449+
fontsize : int or str
450450
rot : label rotation angle
451451
grid : Setting this to True will show the grid
452452
ax : Matplotlib axis object, default None
@@ -530,7 +530,7 @@ class PlotAccessor(PandasObject):
530530
figsize : a tuple (width, height) in inches
531531
use_index : bool, default True
532532
Use index as ticks for x axis
533-
title : string or list
533+
title : str or list
534534
Title to use for the plot. If a string is passed, print the string
535535
at the top of the figure. If a list is passed and `subplots` is
536536
True, print each item in the list above the corresponding subplot.
@@ -553,16 +553,16 @@ class PlotAccessor(PandasObject):
553553
.. versionchanged:: 0.25.0
554554
555555
xticks : sequence
556-
Values to use for the xticks
556+
Values to use for the xticks.
557557
yticks : sequence
558-
Values to use for the yticks
558+
Values to use for the yticks.
559559
xlim : 2-tuple/list
560560
ylim : 2-tuple/list
561561
rot : int, default None
562562
Rotation for ticks (xticks for vertical, yticks for horizontal
563563
plots)
564564
fontsize : int, default None
565-
Font size for xticks and yticks
565+
Font size for xticks and yticks.
566566
colormap : str or matplotlib colormap object, default None
567567
Colormap to select colors from. If string, load colormap with that
568568
name from matplotlib.
@@ -587,9 +587,9 @@ class PlotAccessor(PandasObject):
587587
When using a secondary_y axis, automatically mark the column
588588
labels with "(right)" in the legend
589589
include_bool : bool, default is False
590-
If True, boolean values can be plotted
590+
If True, boolean values can be plotted.
591591
`**kwds` : keywords
592-
Options to pass to matplotlib plotting method
592+
Options to pass to matplotlib plotting method.
593593
594594
Returns
595595
-------
@@ -985,7 +985,7 @@ def barh(self, x=None, y=None, **kwargs):
985985
.. plot::
986986
:context: close-figs
987987
988-
>>> df = pd.DataFrame({'lab':['A', 'B', 'C'], 'val':[10, 30, 20]})
988+
>>> df = pd.DataFrame({'lab': ['A', 'B', 'C'], 'val': [10, 30, 20]})
989989
>>> ax = df.plot.barh(x='lab', y='val')
990990
991991
Plot a whole DataFrame to a horizontal bar plot
@@ -1049,7 +1049,7 @@ def box(self, by=None, **kwargs):
10491049
10501050
Parameters
10511051
----------
1052-
by : string or sequence
1052+
by : str or sequence
10531053
Column in the DataFrame to group by.
10541054
**kwds : optional
10551055
Additional keywords are documented in

0 commit comments

Comments
 (0)