Skip to content

Commit 680c1c4

Browse files
undo and merge
2 parents 65ebcda + f74fc59 commit 680c1c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+904
-876
lines changed

pandas/core/algorithms.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ def unique(values):
289289
- If the input is a Categorical dtype, the return is a Categorical
290290
- If the input is a Series/ndarray, the return will be an ndarray
291291
292+
See Also
293+
--------
294+
pandas.Index.unique
295+
pandas.Series.unique
296+
292297
Examples
293298
--------
294299
>>> pd.unique(pd.Series([2, 1, 3, 3]))
@@ -338,11 +343,6 @@ def unique(values):
338343
339344
>>> pd.unique([('a', 'b'), ('b', 'a'), ('a', 'c'), ('b', 'a')])
340345
array([('a', 'b'), ('b', 'a'), ('a', 'c')], dtype=object)
341-
342-
See Also
343-
--------
344-
pandas.Index.unique
345-
pandas.Series.unique
346346
"""
347347

348348
values = _ensure_arraylike(values)

pandas/core/arrays/categorical.py

+38-38
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ class Categorical(ExtensionArray, PandasObject):
273273
If an explicit ``ordered=True`` is given but no `categories` and the
274274
`values` are not sortable.
275275
276+
See Also
277+
--------
278+
pandas.api.types.CategoricalDtype : Type for categorical data.
279+
CategoricalIndex : An Index with an underlying ``Categorical``.
280+
281+
Notes
282+
-----
283+
See the `user guide
284+
<http://pandas.pydata.org/pandas-docs/stable/categorical.html>`_ for more.
285+
276286
Examples
277287
--------
278288
>>> pd.Categorical([1, 2, 3, 1, 2, 3])
@@ -293,16 +303,6 @@ class Categorical(ExtensionArray, PandasObject):
293303
Categories (3, object): [c < b < a]
294304
>>> c.min()
295305
'c'
296-
297-
Notes
298-
-----
299-
See the `user guide
300-
<http://pandas.pydata.org/pandas-docs/stable/categorical.html>`_ for more.
301-
302-
See Also
303-
--------
304-
pandas.api.types.CategoricalDtype : Type for categorical data.
305-
CategoricalIndex : An Index with an underlying ``Categorical``.
306306
"""
307307

308308
# For comparisons, so that numpy uses our implementation if the compare
@@ -827,11 +827,6 @@ def set_categories(self, new_categories, ordered=None, rename=False,
827827
dtypes on python3, which does not considers a S1 string equal to a
828828
single char python string.
829829
830-
Raises
831-
------
832-
ValueError
833-
If new_categories does not validate as categories
834-
835830
Parameters
836831
----------
837832
new_categories : Index-like
@@ -850,6 +845,11 @@ def set_categories(self, new_categories, ordered=None, rename=False,
850845
-------
851846
cat : Categorical with reordered categories or None if inplace.
852847
848+
Raises
849+
------
850+
ValueError
851+
If new_categories does not validate as categories
852+
853853
See Also
854854
--------
855855
rename_categories
@@ -882,12 +882,6 @@ def rename_categories(self, new_categories, inplace=False):
882882
"""
883883
Renames categories.
884884
885-
Raises
886-
------
887-
ValueError
888-
If new categories are list-like and do not have the same number of
889-
items than the current categories or do not validate as categories
890-
891885
Parameters
892886
----------
893887
new_categories : list-like, dict-like or callable
@@ -922,6 +916,12 @@ def rename_categories(self, new_categories, inplace=False):
922916
With ``inplace=False``, the new categorical is returned.
923917
With ``inplace=True``, there is no return value.
924918
919+
Raises
920+
------
921+
ValueError
922+
If new categories are list-like and do not have the same number of
923+
items than the current categories or do not validate as categories
924+
925925
See Also
926926
--------
927927
reorder_categories
@@ -979,12 +979,6 @@ def reorder_categories(self, new_categories, ordered=None, inplace=False):
979979
`new_categories` need to include all old categories and no new category
980980
items.
981981
982-
Raises
983-
------
984-
ValueError
985-
If the new categories do not contain all old category items or any
986-
new ones
987-
988982
Parameters
989983
----------
990984
new_categories : Index-like
@@ -1000,6 +994,12 @@ def reorder_categories(self, new_categories, ordered=None, inplace=False):
1000994
-------
1001995
cat : Categorical with reordered categories or None if inplace.
1002996
997+
Raises
998+
------
999+
ValueError
1000+
If the new categories do not contain all old category items or any
1001+
new ones
1002+
10031003
See Also
10041004
--------
10051005
rename_categories
@@ -1022,12 +1022,6 @@ def add_categories(self, new_categories, inplace=False):
10221022
`new_categories` will be included at the last/highest place in the
10231023
categories and will be unused directly after this call.
10241024
1025-
Raises
1026-
------
1027-
ValueError
1028-
If the new categories include old categories or do not validate as
1029-
categories
1030-
10311025
Parameters
10321026
----------
10331027
new_categories : category or list-like of category
@@ -1040,6 +1034,12 @@ def add_categories(self, new_categories, inplace=False):
10401034
-------
10411035
cat : Categorical with new categories added or None if inplace.
10421036
1037+
Raises
1038+
------
1039+
ValueError
1040+
If the new categories include old categories or do not validate as
1041+
categories
1042+
10431043
See Also
10441044
--------
10451045
rename_categories
@@ -1072,11 +1072,6 @@ def remove_categories(self, removals, inplace=False):
10721072
`removals` must be included in the old categories. Values which were in
10731073
the removed categories will be set to NaN
10741074
1075-
Raises
1076-
------
1077-
ValueError
1078-
If the removals are not contained in the categories
1079-
10801075
Parameters
10811076
----------
10821077
removals : category or list of categories
@@ -1089,6 +1084,11 @@ def remove_categories(self, removals, inplace=False):
10891084
-------
10901085
cat : Categorical with removed categories or None if inplace.
10911086
1087+
Raises
1088+
------
1089+
ValueError
1090+
If the removals are not contained in the categories
1091+
10921092
See Also
10931093
--------
10941094
rename_categories

pandas/core/arrays/datetimes.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,11 @@ def to_period(self, freq=None):
892892
When converting a DatetimeArray/Index with non-regular values,
893893
so that a frequency cannot be inferred.
894894
895+
See Also
896+
--------
897+
PeriodIndex: Immutable ndarray holding ordinal values.
898+
DatetimeIndex.to_pydatetime: Return DatetimeIndex as object.
899+
895900
Examples
896901
--------
897902
>>> df = pd.DataFrame({"y": [1,2,3]},
@@ -908,11 +913,6 @@ def to_period(self, freq=None):
908913
>>> idx.to_period()
909914
PeriodIndex(['2017-01-01', '2017-01-02'],
910915
dtype='period[D]', freq='D')
911-
912-
See Also
913-
--------
914-
PeriodIndex: Immutable ndarray holding ordinal values.
915-
DatetimeIndex.to_pydatetime: Return DatetimeIndex as object.
916916
"""
917917
from pandas.core.arrays import PeriodArray
918918

@@ -1087,17 +1087,17 @@ def date(self):
10871087
by 6. This method is available on both Series with datetime
10881088
values (using the `dt` accessor) or DatetimeIndex.
10891089
1090+
Returns
1091+
-------
1092+
Series or Index
1093+
Containing integers indicating the day number.
1094+
10901095
See Also
10911096
--------
10921097
Series.dt.dayofweek : Alias.
10931098
Series.dt.weekday : Alias.
10941099
Series.dt.day_name : Returns the name of the day of the week.
10951100
1096-
Returns
1097-
-------
1098-
Series or Index
1099-
Containing integers indicating the day number.
1100-
11011101
Examples
11021102
--------
11031103
>>> s = pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series()

pandas/core/arrays/interval.py

+41-43
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@
8484
set_closed
8585
%(extra_methods)s\
8686
87-
%(examples)s\
88-
89-
Notes
90-
------
91-
See the `user guide
92-
<http://pandas.pydata.org/pandas-docs/stable/advanced.html#intervalindex>`_
93-
for more.
94-
9587
See Also
9688
--------
9789
Index : The base pandas Index type.
9890
Interval : A bounded slice-like interval; the elements of an %(klass)s.
9991
interval_range : Function to create a fixed frequency IntervalIndex.
10092
cut : Bin values into discrete Intervals.
10193
qcut : Bin values into equal-sized Intervals based on rank or sample quantiles.
94+
95+
Notes
96+
------
97+
See the `user guide
98+
<http://pandas.pydata.org/pandas-docs/stable/advanced.html#intervalindex>`_
99+
for more.
100+
101+
%(examples)s\
102102
"""
103103

104104

@@ -236,18 +236,18 @@ def _from_factorized(cls, values, original):
236236
237237
.. versionadded:: 0.23.0
238238
239+
See Also
240+
--------
241+
interval_range : Function to create a fixed frequency IntervalIndex.
242+
%(klass)s.from_arrays : Construct from a left and right array.
243+
%(klass)s.from_tuples : Construct from a sequence of tuples.
244+
239245
Examples
240246
--------
241247
>>> pd.%(klass)s.from_breaks([0, 1, 2, 3])
242248
%(klass)s([(0, 1], (1, 2], (2, 3]]
243249
closed='right',
244250
dtype='interval[int64]')
245-
246-
See Also
247-
--------
248-
interval_range : Function to create a fixed frequency IntervalIndex.
249-
%(klass)s.from_arrays : Construct from a left and right array.
250-
%(klass)s.from_tuples : Construct from a sequence of tuples.
251251
"""
252252

253253
@classmethod
@@ -281,14 +281,6 @@ def from_breaks(cls, breaks, closed='right', copy=False, dtype=None):
281281
-------
282282
%(klass)s
283283
284-
Notes
285-
-----
286-
Each element of `left` must be less than or equal to the `right`
287-
element at the same position. If an element is missing, it must be
288-
missing in both `left` and `right`. A TypeError is raised when
289-
using an unsupported type for `left` or `right`. At the moment,
290-
'category', 'object', and 'string' subtypes are not supported.
291-
292284
Raises
293285
------
294286
ValueError
@@ -304,6 +296,13 @@ def from_breaks(cls, breaks, closed='right', copy=False, dtype=None):
304296
%(klass)s.from_tuples : Construct an %(klass)s from an
305297
array-like of tuples.
306298
299+
Notes
300+
-----
301+
Each element of `left` must be less than or equal to the `right`
302+
element at the same position. If an element is missing, it must be
303+
missing in both `left` and `right`. A TypeError is raised when
304+
using an unsupported type for `left` or `right`. At the moment,
305+
'category', 'object', and 'string' subtypes are not supported.
307306
308307
Examples
309308
--------
@@ -339,6 +338,16 @@ def from_arrays(cls, left, right, closed='right', copy=False, dtype=None):
339338
340339
..versionadded:: 0.23.0
341340
341+
See Also
342+
--------
343+
interval_range : Function to create a fixed frequency IntervalIndex.
344+
%(klass)s.from_arrays : Construct an %(klass)s from a left and
345+
right array.
346+
%(klass)s.from_breaks : Construct an %(klass)s from an array of
347+
splits.
348+
%(klass)s.from_tuples : Construct an %(klass)s from an
349+
array-like of tuples.
350+
342351
Examples
343352
--------
344353
>>> pd.%(klass)s.from_intervals([pd.Interval(0, 1),
@@ -352,16 +361,6 @@ def from_arrays(cls, left, right, closed='right', copy=False, dtype=None):
352361
>>> pd.Index([pd.Interval(0, 1), pd.Interval(1, 2)])
353362
%(klass)s([(0, 1], (1, 2]]
354363
closed='right', dtype='interval[int64]')
355-
356-
See Also
357-
--------
358-
interval_range : Function to create a fixed frequency IntervalIndex.
359-
%(klass)s.from_arrays : Construct an %(klass)s from a left and
360-
right array.
361-
%(klass)s.from_breaks : Construct an %(klass)s from an array of
362-
splits.
363-
%(klass)s.from_tuples : Construct an %(klass)s from an
364-
array-like of tuples.
365364
"""
366365

367366
_interval_shared_docs['from_tuples'] = """
@@ -381,20 +380,19 @@ def from_arrays(cls, left, right, closed='right', copy=False, dtype=None):
381380
382381
..versionadded:: 0.23.0
383382
384-
385-
Examples
386-
--------
387-
>>> pd.%(klass)s.from_tuples([(0, 1), (1, 2)])
388-
%(klass)s([(0, 1], (1, 2]],
389-
closed='right', dtype='interval[int64]')
390-
391383
See Also
392384
--------
393385
interval_range : Function to create a fixed frequency IntervalIndex.
394386
%(klass)s.from_arrays : Construct an %(klass)s from a left and
395387
right array.
396388
%(klass)s.from_breaks : Construct an %(klass)s from an array of
397389
splits.
390+
391+
Examples
392+
--------
393+
>>> pd.%(klass)s.from_tuples([(0, 1), (1, 2)])
394+
%(klass)s([(0, 1], (1, 2]],
395+
closed='right', dtype='interval[int64]')
398396
"""
399397

400398
@classmethod
@@ -1052,6 +1050,10 @@ def repeat(self, repeats, **kwargs):
10521050
ndarray
10531051
Boolean array positionally indicating where an overlap occurs.
10541052
1053+
See Also
1054+
--------
1055+
Interval.overlaps : Check whether two Interval objects overlap.
1056+
10551057
Examples
10561058
--------
10571059
>>> intervals = %(constructor)s.from_tuples([(0, 1), (1, 3), (2, 4)])
@@ -1071,10 +1073,6 @@ def repeat(self, repeats, **kwargs):
10711073
10721074
>>> intervals.overlaps(pd.Interval(1, 2, closed='right'))
10731075
array([False, True, False])
1074-
1075-
See Also
1076-
--------
1077-
Interval.overlaps : Check whether two Interval objects overlap.
10781076
"""
10791077

10801078
@Appender(_interval_shared_docs['overlaps'] % _shared_docs_kwargs)

0 commit comments

Comments
 (0)