Skip to content

Commit

Permalink
Merge branch 'main' into pandas.Index
Browse files Browse the repository at this point in the history
  • Loading branch information
aBiR1D committed Apr 30, 2024
2 parents 497e42a + fdcdcb8 commit 5b0dc04
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 7 deletions.
5 changes: 0 additions & 5 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
--format=actions \
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
-i "pandas.DataFrame.__dataframe__ SA01" \
-i "pandas.DataFrame.at_time PR01" \
-i "pandas.DataFrame.kurt RT03,SA01" \
-i "pandas.DataFrame.kurtosis RT03,SA01" \
-i "pandas.DataFrame.max RT03" \
-i "pandas.DataFrame.mean RT03,SA01" \
-i "pandas.DataFrame.median RT03,SA01" \
Expand All @@ -100,9 +97,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Index.names GL08" \
-i "pandas.Index.putmask PR01,RT03" \
-i "pandas.Index.ravel PR01,RT03" \
-i "pandas.Index.slice_indexer PR07,RT03,SA01" \
-i "pandas.Index.str PR01,SA01" \
-i "pandas.Index.take PR01,PR07" \
-i "pandas.Index.view GL08" \
-i "pandas.Int16Dtype SA01" \
-i "pandas.Int32Dtype SA01" \
Expand Down
85 changes: 84 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ def __dataframe__(
DataFrame interchange object
The object which consuming library can use to ingress the dataframe.
See Also
--------
DataFrame.from_records : Constructor from tuples, also record arrays.
DataFrame.from_dict : From dicts of Series, arrays, or dicts.
Notes
-----
Details on the interchange protocol:
Expand Down Expand Up @@ -12064,14 +12069,92 @@ def kurt(
) -> Series | Any: ...

@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="kurt")
@doc(make_doc("kurt", ndim=2))
def kurt(
self,
axis: Axis | None = 0,
skipna: bool = True,
numeric_only: bool = False,
**kwargs,
) -> Series | Any:
"""
Return unbiased kurtosis over requested axis.
Kurtosis obtained using Fisher's definition of
kurtosis (kurtosis of normal == 0.0). Normalized by N-1.
Parameters
----------
axis : {index (0), columns (1)}
Axis for the function to be applied on.
For `Series` this parameter is unused and defaults to 0.
For DataFrames, specifying ``axis=None`` will apply the aggregation
across both axes.
.. versionadded:: 2.0.0
skipna : bool, default True
Exclude NA/null values when computing the result.
numeric_only : bool, default False
Include only float, int, boolean columns.
**kwargs
Additional keyword arguments to be passed to the function.
Returns
-------
Series or scalar
Unbiased kurtosis over requested axis.
See Also
--------
Dataframe.kurtosis : Returns unbiased kurtosis over requested axis.
Examples
--------
>>> s = pd.Series([1, 2, 2, 3], index=["cat", "dog", "dog", "mouse"])
>>> s
cat 1
dog 2
dog 2
mouse 3
dtype: int64
>>> s.kurt()
1.5
With a DataFrame
>>> df = pd.DataFrame(
... {"a": [1, 2, 2, 3], "b": [3, 4, 4, 4]},
... index=["cat", "dog", "dog", "mouse"],
... )
>>> df
a b
cat 1 3
dog 2 4
dog 2 4
mouse 3 4
>>> df.kurt()
a 1.5
b 4.0
dtype: float64
With axis=None
>>> df.kurt(axis=None).round(6)
-0.988693
Using axis=1
>>> df = pd.DataFrame(
... {"a": [1, 2], "b": [3, 4], "c": [3, 4], "d": [1, 2]},
... index=["cat", "dog"],
... )
>>> df.kurt(axis=1)
cat -6.0
dog -6.0
dtype: float64
"""
result = super().kurt(
axis=axis, skipna=skipna, numeric_only=numeric_only, **kwargs
)
Expand Down
21 changes: 20 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,9 +1121,21 @@ def astype(self, dtype, copy: bool = True):
axis : int, optional
The axis over which to select values, always 0.
allow_fill : bool, default True
How to handle negative values in `indices`.
* False: negative values in `indices` indicate positional indices
from the right (the default). This is similar to
:func:`numpy.take`.
* True: negative values in `indices` indicate
missing values. These values are set to `fill_value`. Any other
other negative values raise a ``ValueError``.
fill_value : scalar, default None
If allow_fill=True and fill_value is not None, indices specified by
-1 are regarded as NA. If Index doesn't hold NA, raise ValueError.
**kwargs
Required for compatibility with numpy.
Returns
-------
Expand Down Expand Up @@ -6331,19 +6343,26 @@ def slice_indexer(
end : label, default None
If None, defaults to the end.
step : int, default None
If None, defaults to 1.
Returns
-------
slice
A slice object.
Raises
------
KeyError : If key does not exist, or key is not unique and index is
not ordered.
See Also
--------
Index.slice_locs : Computes slice locations for input labels.
Index.get_slice_bound : Retrieves slice bound that corresponds to given label.
Notes
-----
This function assumes that the data is sorted, so use at your own peril
This function assumes that the data is sorted, so use at your own peril.
Examples
--------
Expand Down

0 comments on commit 5b0dc04

Please sign in to comment.