Skip to content

Commit dc42231

Browse files
Daniel SaxtonPingviinituutti
Daniel Saxton
authored andcommitted
DOC/CLN: Fix errors in DataFrame docstrings (pandas-dev#24952)
1 parent b508690 commit dc42231

File tree

2 files changed

+71
-64
lines changed

2 files changed

+71
-64
lines changed

pandas/core/frame.py

+58-51
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ def from_dict(cls, data, orient='columns', dtype=None, columns=None):
10651065
10661066
Returns
10671067
-------
1068-
pandas.DataFrame
1068+
DataFrame
10691069
10701070
See Also
10711071
--------
@@ -1145,7 +1145,7 @@ def to_numpy(self, dtype=None, copy=False):
11451145
11461146
Returns
11471147
-------
1148-
array : numpy.ndarray
1148+
numpy.ndarray
11491149
11501150
See Also
11511151
--------
@@ -1439,7 +1439,7 @@ def from_records(cls, data, index=None, exclude=None, columns=None,
14391439
14401440
Returns
14411441
-------
1442-
df : DataFrame
1442+
DataFrame
14431443
"""
14441444

14451445
# Make a copy of the input columns so we can modify it
@@ -1755,7 +1755,7 @@ def from_items(cls, items, columns=None, orient='columns'):
17551755
17561756
Returns
17571757
-------
1758-
frame : DataFrame
1758+
DataFrame
17591759
"""
17601760

17611761
warnings.warn("from_items is deprecated. Please use "
@@ -1866,7 +1866,7 @@ def from_csv(cls, path, header=0, sep=',', index_col=0, parse_dates=True,
18661866
18671867
Returns
18681868
-------
1869-
y : DataFrame
1869+
DataFrame
18701870
18711871
See Also
18721872
--------
@@ -1956,7 +1956,7 @@ def to_panel(self):
19561956
19571957
Returns
19581958
-------
1959-
panel : Panel
1959+
Panel
19601960
"""
19611961
raise NotImplementedError("Panel is being removed in pandas 0.25.0.")
19621962

@@ -2478,7 +2478,7 @@ def memory_usage(self, index=True, deep=False):
24782478
24792479
Returns
24802480
-------
2481-
sizes : Series
2481+
Series
24822482
A Series whose index is the original column names and whose values
24832483
is the memory usage of each column in bytes.
24842484
@@ -2696,7 +2696,7 @@ def get_value(self, index, col, takeable=False):
26962696
26972697
Returns
26982698
-------
2699-
value : scalar value
2699+
scalar value
27002700
"""
27012701

27022702
warnings.warn("get_value is deprecated and will be removed "
@@ -2741,7 +2741,7 @@ def set_value(self, index, col, value, takeable=False):
27412741
27422742
Returns
27432743
-------
2744-
frame : DataFrame
2744+
DataFrame
27452745
If label pair is contained, will be reference to calling DataFrame,
27462746
otherwise a new object
27472747
"""
@@ -3177,7 +3177,7 @@ def select_dtypes(self, include=None, exclude=None):
31773177
31783178
Returns
31793179
-------
3180-
subset : DataFrame
3180+
DataFrame
31813181
The subset of the frame including the dtypes in ``include`` and
31823182
excluding the dtypes in ``exclude``.
31833183
@@ -3542,7 +3542,7 @@ def _sanitize_column(self, key, value, broadcast=True):
35423542
35433543
Returns
35443544
-------
3545-
sanitized_column : numpy-array
3545+
numpy.ndarray
35463546
"""
35473547

35483548
def reindexer(value):
@@ -3811,7 +3811,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
38113811
38123812
Returns
38133813
-------
3814-
dropped : pandas.DataFrame
3814+
DataFrame
38153815
38163816
Raises
38173817
------
@@ -3936,7 +3936,7 @@ def rename(self, *args, **kwargs):
39363936
39373937
Returns
39383938
-------
3939-
renamed : DataFrame
3939+
DataFrame
39403940
39413941
See Also
39423942
--------
@@ -4579,7 +4579,7 @@ def drop_duplicates(self, subset=None, keep='first', inplace=False):
45794579
45804580
Returns
45814581
-------
4582-
deduplicated : DataFrame
4582+
DataFrame
45834583
"""
45844584
if self.empty:
45854585
return self.copy()
@@ -4613,7 +4613,7 @@ def duplicated(self, subset=None, keep='first'):
46134613
46144614
Returns
46154615
-------
4616-
duplicated : Series
4616+
Series
46174617
"""
46184618
from pandas.core.sorting import get_group_index
46194619
from pandas._libs.hashtable import duplicated_int64, _SIZE_HINT_LIMIT
@@ -4981,7 +4981,7 @@ def swaplevel(self, i=-2, j=-1, axis=0):
49814981
49824982
Returns
49834983
-------
4984-
swapped : same type as caller (new object)
4984+
DataFrame
49854985
49864986
.. versionchanged:: 0.18.1
49874987
@@ -5260,7 +5260,7 @@ def combine_first(self, other):
52605260
52615261
Returns
52625262
-------
5263-
combined : DataFrame
5263+
DataFrame
52645264
52655265
See Also
52665266
--------
@@ -5621,7 +5621,7 @@ def pivot(self, index=None, columns=None, values=None):
56215621
56225622
Returns
56235623
-------
5624-
table : DataFrame
5624+
DataFrame
56255625
56265626
See Also
56275627
--------
@@ -5907,7 +5907,7 @@ def unstack(self, level=-1, fill_value=None):
59075907
59085908
Returns
59095909
-------
5910-
unstacked : DataFrame or Series
5910+
Series or DataFrame
59115911
59125912
See Also
59135913
--------
@@ -6073,7 +6073,7 @@ def diff(self, periods=1, axis=0):
60736073
60746074
Returns
60756075
-------
6076-
diffed : DataFrame
6076+
DataFrame
60776077
60786078
See Also
60796079
--------
@@ -6345,7 +6345,7 @@ def apply(self, func, axis=0, broadcast=None, raw=False, reduce=None,
63456345
63466346
Returns
63476347
-------
6348-
applied : Series or DataFrame
6348+
Series or DataFrame
63496349
63506350
See Also
63516351
--------
@@ -6538,7 +6538,7 @@ def append(self, other, ignore_index=False,
65386538
65396539
Returns
65406540
-------
6541-
appended : DataFrame
6541+
DataFrame
65426542
65436543
See Also
65446544
--------
@@ -6956,12 +6956,13 @@ def corr(self, method='pearson', min_periods=1):
69566956
69576957
min_periods : int, optional
69586958
Minimum number of observations required per pair of columns
6959-
to have a valid result. Currently only available for pearson
6960-
and spearman correlation
6959+
to have a valid result. Currently only available for Pearson
6960+
and Spearman correlation.
69616961
69626962
Returns
69636963
-------
6964-
y : DataFrame
6964+
DataFrame
6965+
Correlation matrix.
69656966
69666967
See Also
69676968
--------
@@ -6970,14 +6971,15 @@ def corr(self, method='pearson', min_periods=1):
69706971
69716972
Examples
69726973
--------
6973-
>>> histogram_intersection = lambda a, b: np.minimum(a, b
6974-
... ).sum().round(decimals=1)
6974+
>>> def histogram_intersection(a, b):
6975+
... v = np.minimum(a, b).sum().round(decimals=1)
6976+
... return v
69756977
>>> df = pd.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)],
69766978
... columns=['dogs', 'cats'])
69776979
>>> df.corr(method=histogram_intersection)
6978-
dogs cats
6979-
dogs 1.0 0.3
6980-
cats 0.3 1.0
6980+
dogs cats
6981+
dogs 1.0 0.3
6982+
cats 0.3 1.0
69816983
"""
69826984
numeric_df = self._get_numeric_data()
69836985
cols = numeric_df.columns
@@ -7140,10 +7142,11 @@ def corrwith(self, other, axis=0, drop=False, method='pearson'):
71407142
Parameters
71417143
----------
71427144
other : DataFrame, Series
7145+
Object with which to compute correlations.
71437146
axis : {0 or 'index', 1 or 'columns'}, default 0
7144-
0 or 'index' to compute column-wise, 1 or 'columns' for row-wise
7145-
drop : boolean, default False
7146-
Drop missing indices from result
7147+
0 or 'index' to compute column-wise, 1 or 'columns' for row-wise.
7148+
drop : bool, default False
7149+
Drop missing indices from result.
71477150
method : {'pearson', 'kendall', 'spearman'} or callable
71487151
* pearson : standard correlation coefficient
71497152
* kendall : Kendall Tau correlation coefficient
@@ -7155,7 +7158,8 @@ def corrwith(self, other, axis=0, drop=False, method='pearson'):
71557158
71567159
Returns
71577160
-------
7158-
correls : Series
7161+
Series
7162+
Pairwise correlations.
71597163
71607164
See Also
71617165
-------
@@ -7485,7 +7489,7 @@ def nunique(self, axis=0, dropna=True):
74857489
74867490
Returns
74877491
-------
7488-
nunique : Series
7492+
Series
74897493
74907494
See Also
74917495
--------
@@ -7523,7 +7527,8 @@ def idxmin(self, axis=0, skipna=True):
75237527
75247528
Returns
75257529
-------
7526-
idxmin : Series
7530+
Series
7531+
Indexes of minima along the specified axis.
75277532
75287533
Raises
75297534
------
@@ -7559,7 +7564,8 @@ def idxmax(self, axis=0, skipna=True):
75597564
75607565
Returns
75617566
-------
7562-
idxmax : Series
7567+
Series
7568+
Indexes of maxima along the specified axis.
75637569
75647570
Raises
75657571
------
@@ -7706,7 +7712,7 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
77067712
77077713
Returns
77087714
-------
7709-
quantiles : Series or DataFrame
7715+
Series or DataFrame
77107716
77117717
If ``q`` is an array, a DataFrame will be returned where the
77127718
index is ``q``, the columns are the columns of self, and the
@@ -7776,19 +7782,19 @@ def to_timestamp(self, freq=None, how='start', axis=0, copy=True):
77767782
77777783
Parameters
77787784
----------
7779-
freq : string, default frequency of PeriodIndex
7780-
Desired frequency
7785+
freq : str, default frequency of PeriodIndex
7786+
Desired frequency.
77817787
how : {'s', 'e', 'start', 'end'}
77827788
Convention for converting period to timestamp; start of period
7783-
vs. end
7789+
vs. end.
77847790
axis : {0 or 'index', 1 or 'columns'}, default 0
7785-
The axis to convert (the index by default)
7786-
copy : boolean, default True
7787-
If false then underlying input data is not copied
7791+
The axis to convert (the index by default).
7792+
copy : bool, default True
7793+
If False then underlying input data is not copied.
77887794
77897795
Returns
77907796
-------
7791-
df : DataFrame with DatetimeIndex
7797+
DataFrame with DatetimeIndex
77927798
"""
77937799
new_data = self._data
77947800
if copy:
@@ -7812,15 +7818,16 @@ def to_period(self, freq=None, axis=0, copy=True):
78127818
78137819
Parameters
78147820
----------
7815-
freq : string, default
7821+
freq : str, default
7822+
Frequency of the PeriodIndex.
78167823
axis : {0 or 'index', 1 or 'columns'}, default 0
7817-
The axis to convert (the index by default)
7818-
copy : boolean, default True
7819-
If False then underlying input data is not copied
7824+
The axis to convert (the index by default).
7825+
copy : bool, default True
7826+
If False then underlying input data is not copied.
78207827
78217828
Returns
78227829
-------
7823-
ts : TimeSeries with PeriodIndex
7830+
TimeSeries with PeriodIndex
78247831
"""
78257832
new_data = self._data
78267833
if copy:
@@ -7893,7 +7900,7 @@ def isin(self, values):
78937900
match. Note that 'falcon' does not match based on the number of legs
78947901
in df2.
78957902
7896-
>>> other = pd.DataFrame({'num_legs': [8, 2],'num_wings': [0, 2]},
7903+
>>> other = pd.DataFrame({'num_legs': [8, 2], 'num_wings': [0, 2]},
78977904
... index=['spider', 'falcon'])
78987905
>>> df.isin(other)
78997906
num_legs num_wings

0 commit comments

Comments
 (0)