Skip to content

Commit 5b0dc04

Browse files
authored
Merge branch 'main' into pandas.Index
2 parents 497e42a + fdcdcb8 commit 5b0dc04

File tree

3 files changed

+104
-7
lines changed

3 files changed

+104
-7
lines changed

ci/code_checks.sh

-5
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7070
--format=actions \
7171
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
73-
-i "pandas.DataFrame.__dataframe__ SA01" \
7473
-i "pandas.DataFrame.at_time PR01" \
75-
-i "pandas.DataFrame.kurt RT03,SA01" \
76-
-i "pandas.DataFrame.kurtosis RT03,SA01" \
7774
-i "pandas.DataFrame.max RT03" \
7875
-i "pandas.DataFrame.mean RT03,SA01" \
7976
-i "pandas.DataFrame.median RT03,SA01" \
@@ -100,9 +97,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
10097
-i "pandas.Index.names GL08" \
10198
-i "pandas.Index.putmask PR01,RT03" \
10299
-i "pandas.Index.ravel PR01,RT03" \
103-
-i "pandas.Index.slice_indexer PR07,RT03,SA01" \
104100
-i "pandas.Index.str PR01,SA01" \
105-
-i "pandas.Index.take PR01,PR07" \
106101
-i "pandas.Index.view GL08" \
107102
-i "pandas.Int16Dtype SA01" \
108103
-i "pandas.Int32Dtype SA01" \

pandas/core/frame.py

+84-1
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,11 @@ def __dataframe__(
931931
DataFrame interchange object
932932
The object which consuming library can use to ingress the dataframe.
933933
934+
See Also
935+
--------
936+
DataFrame.from_records : Constructor from tuples, also record arrays.
937+
DataFrame.from_dict : From dicts of Series, arrays, or dicts.
938+
934939
Notes
935940
-----
936941
Details on the interchange protocol:
@@ -12064,14 +12069,92 @@ def kurt(
1206412069
) -> Series | Any: ...
1206512070

1206612071
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="kurt")
12067-
@doc(make_doc("kurt", ndim=2))
1206812072
def kurt(
1206912073
self,
1207012074
axis: Axis | None = 0,
1207112075
skipna: bool = True,
1207212076
numeric_only: bool = False,
1207312077
**kwargs,
1207412078
) -> Series | Any:
12079+
"""
12080+
Return unbiased kurtosis over requested axis.
12081+
12082+
Kurtosis obtained using Fisher's definition of
12083+
kurtosis (kurtosis of normal == 0.0). Normalized by N-1.
12084+
12085+
Parameters
12086+
----------
12087+
axis : {index (0), columns (1)}
12088+
Axis for the function to be applied on.
12089+
For `Series` this parameter is unused and defaults to 0.
12090+
12091+
For DataFrames, specifying ``axis=None`` will apply the aggregation
12092+
across both axes.
12093+
12094+
.. versionadded:: 2.0.0
12095+
12096+
skipna : bool, default True
12097+
Exclude NA/null values when computing the result.
12098+
numeric_only : bool, default False
12099+
Include only float, int, boolean columns.
12100+
12101+
**kwargs
12102+
Additional keyword arguments to be passed to the function.
12103+
12104+
Returns
12105+
-------
12106+
Series or scalar
12107+
Unbiased kurtosis over requested axis.
12108+
12109+
See Also
12110+
--------
12111+
Dataframe.kurtosis : Returns unbiased kurtosis over requested axis.
12112+
12113+
Examples
12114+
--------
12115+
>>> s = pd.Series([1, 2, 2, 3], index=["cat", "dog", "dog", "mouse"])
12116+
>>> s
12117+
cat 1
12118+
dog 2
12119+
dog 2
12120+
mouse 3
12121+
dtype: int64
12122+
>>> s.kurt()
12123+
1.5
12124+
12125+
With a DataFrame
12126+
12127+
>>> df = pd.DataFrame(
12128+
... {"a": [1, 2, 2, 3], "b": [3, 4, 4, 4]},
12129+
... index=["cat", "dog", "dog", "mouse"],
12130+
... )
12131+
>>> df
12132+
a b
12133+
cat 1 3
12134+
dog 2 4
12135+
dog 2 4
12136+
mouse 3 4
12137+
>>> df.kurt()
12138+
a 1.5
12139+
b 4.0
12140+
dtype: float64
12141+
12142+
With axis=None
12143+
12144+
>>> df.kurt(axis=None).round(6)
12145+
-0.988693
12146+
12147+
Using axis=1
12148+
12149+
>>> df = pd.DataFrame(
12150+
... {"a": [1, 2], "b": [3, 4], "c": [3, 4], "d": [1, 2]},
12151+
... index=["cat", "dog"],
12152+
... )
12153+
>>> df.kurt(axis=1)
12154+
cat -6.0
12155+
dog -6.0
12156+
dtype: float64
12157+
"""
1207512158
result = super().kurt(
1207612159
axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
1207712160
)

pandas/core/indexes/base.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -1121,9 +1121,21 @@ def astype(self, dtype, copy: bool = True):
11211121
axis : int, optional
11221122
The axis over which to select values, always 0.
11231123
allow_fill : bool, default True
1124+
How to handle negative values in `indices`.
1125+
1126+
* False: negative values in `indices` indicate positional indices
1127+
from the right (the default). This is similar to
1128+
:func:`numpy.take`.
1129+
1130+
* True: negative values in `indices` indicate
1131+
missing values. These values are set to `fill_value`. Any other
1132+
other negative values raise a ``ValueError``.
1133+
11241134
fill_value : scalar, default None
11251135
If allow_fill=True and fill_value is not None, indices specified by
11261136
-1 are regarded as NA. If Index doesn't hold NA, raise ValueError.
1137+
**kwargs
1138+
Required for compatibility with numpy.
11271139
11281140
Returns
11291141
-------
@@ -6331,19 +6343,26 @@ def slice_indexer(
63316343
end : label, default None
63326344
If None, defaults to the end.
63336345
step : int, default None
6346+
If None, defaults to 1.
63346347
63356348
Returns
63366349
-------
63376350
slice
6351+
A slice object.
63386352
63396353
Raises
63406354
------
63416355
KeyError : If key does not exist, or key is not unique and index is
63426356
not ordered.
63436357
6358+
See Also
6359+
--------
6360+
Index.slice_locs : Computes slice locations for input labels.
6361+
Index.get_slice_bound : Retrieves slice bound that corresponds to given label.
6362+
63446363
Notes
63456364
-----
6346-
This function assumes that the data is sorted, so use at your own peril
6365+
This function assumes that the data is sorted, so use at your own peril.
63476366
63486367
Examples
63496368
--------

0 commit comments

Comments
 (0)