Skip to content

Commit 0de1498

Browse files
Merge branch 'main' into np-doc-df-std
2 parents 5663a73 + 51c547b commit 0de1498

File tree

6 files changed

+262
-16
lines changed

6 files changed

+262
-16
lines changed

ci/code_checks.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,12 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7878
-i "pandas.DataFrame.sum RT03" \
7979
-i "pandas.DataFrame.swaplevel SA01" \
8080
-i "pandas.DataFrame.to_markdown SA01" \
81-
-i "pandas.DataFrame.var PR01,RT03,SA01" \
8281
-i "pandas.Grouper PR02" \
8382
-i "pandas.Index PR07" \
8483
-i "pandas.Index.join PR07,RT03,SA01" \
85-
-i "pandas.Index.names GL08" \
8684
-i "pandas.Index.ravel PR01,RT03" \
8785
-i "pandas.Index.str PR01,SA01" \
8886
-i "pandas.Interval PR02" \
89-
-i "pandas.Interval.closed SA01" \
90-
-i "pandas.Interval.left SA01" \
91-
-i "pandas.Interval.mid SA01" \
92-
-i "pandas.Interval.right SA01" \
9387
-i "pandas.IntervalIndex.closed SA01" \
9488
-i "pandas.IntervalIndex.contains RT03" \
9589
-i "pandas.IntervalIndex.get_loc PR07,RT03,SA01" \
@@ -206,9 +200,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
206200
-i "pandas.Series.list.flatten SA01" \
207201
-i "pandas.Series.list.len SA01" \
208202
-i "pandas.Series.lt PR07,SA01" \
209-
-i "pandas.Series.max RT03" \
210203
-i "pandas.Series.mean RT03,SA01" \
211-
-i "pandas.Series.median RT03,SA01" \
212204
-i "pandas.Series.min RT03" \
213205
-i "pandas.Series.mod PR07" \
214206
-i "pandas.Series.mode SA01" \
@@ -302,7 +294,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
302294
-i "pandas.TimedeltaIndex.nanoseconds SA01" \
303295
-i "pandas.TimedeltaIndex.seconds SA01" \
304296
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
305-
-i "pandas.Timestamp PR07,SA01" \
306297
-i "pandas.Timestamp.as_unit SA01" \
307298
-i "pandas.Timestamp.asm8 SA01" \
308299
-i "pandas.Timestamp.astimezone SA01" \
@@ -321,9 +312,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
321312
-i "pandas.Timestamp.isocalendar SA01" \
322313
-i "pandas.Timestamp.isoformat SA01" \
323314
-i "pandas.Timestamp.isoweekday SA01" \
324-
-i "pandas.Timestamp.max PR02,PR07,SA01" \
315+
-i "pandas.Timestamp.max PR02" \
325316
-i "pandas.Timestamp.microsecond GL08" \
326-
-i "pandas.Timestamp.min PR02,PR07,SA01" \
317+
-i "pandas.Timestamp.min PR02" \
327318
-i "pandas.Timestamp.minute GL08" \
328319
-i "pandas.Timestamp.month GL08" \
329320
-i "pandas.Timestamp.month_name SA01" \

pandas/_libs/interval.pyx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ cdef class IntervalMixin:
167167
"""
168168
Return the midpoint of the Interval.
169169
170+
See Also
171+
--------
172+
Interval.left : Return the left bound for the interval.
173+
Interval.right : Return the right bound for the interval.
174+
Interval.length : Return the length of the interval.
175+
170176
Examples
171177
--------
172178
>>> iv = pd.Interval(0, 5)
@@ -377,6 +383,12 @@ cdef class Interval(IntervalMixin):
377383
"""
378384
Left bound for the interval.
379385
386+
See Also
387+
--------
388+
Interval.right : Return the right bound for the interval.
389+
numpy.ndarray.left : A similar method in numpy for obtaining
390+
the left endpoint(s) of intervals.
391+
380392
Examples
381393
--------
382394
>>> interval = pd.Interval(left=1, right=2, closed='left')
@@ -390,6 +402,12 @@ cdef class Interval(IntervalMixin):
390402
"""
391403
Right bound for the interval.
392404
405+
See Also
406+
--------
407+
Interval.left : Return the left bound for the interval.
408+
numpy.ndarray.right : A similar method in numpy for obtaining
409+
the right endpoint(s) of intervals.
410+
393411
Examples
394412
--------
395413
>>> interval = pd.Interval(left=1, right=2, closed='left')
@@ -405,6 +423,13 @@ cdef class Interval(IntervalMixin):
405423
406424
Either ``left``, ``right``, ``both`` or ``neither``.
407425
426+
See Also
427+
--------
428+
Interval.closed_left : Check if the interval is closed on the left side.
429+
Interval.closed_right : Check if the interval is closed on the right side.
430+
Interval.open_left : Check if the interval is open on the left side.
431+
Interval.open_right : Check if the interval is open on the right side.
432+
408433
Examples
409434
--------
410435
>>> interval = pd.Interval(left=1, right=2, closed='left')

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,10 +1297,24 @@ class Timestamp(_Timestamp):
12971297
----------
12981298
ts_input : datetime-like, str, int, float
12991299
Value to be converted to Timestamp.
1300-
year, month, day : int
1301-
hour, minute, second, microsecond : int, optional, default 0
1300+
year : int
1301+
Value of year.
1302+
month : int
1303+
Value of month.
1304+
day : int
1305+
Value of day.
1306+
hour : int, optional, default 0
1307+
Value of hour.
1308+
minute : int, optional, default 0
1309+
Value of minute.
1310+
second : int, optional, default 0
1311+
Value of second.
1312+
microsecond : int, optional, default 0
1313+
Value of microsecond.
13021314
tzinfo : datetime.tzinfo, optional, default None
1315+
Timezone info.
13031316
nanosecond : int, optional, default 0
1317+
Value of nanosecond.
13041318
tz : str, pytz.timezone, dateutil.tz.tzfile or None
13051319
Time zone for time which Timestamp will have.
13061320
unit : str
@@ -1316,6 +1330,11 @@ class Timestamp(_Timestamp):
13161330
datetime-like corresponds to the first (0) or the second time (1)
13171331
the wall clock hits the ambiguous time.
13181332
1333+
See Also
1334+
--------
1335+
Timedelta : Represents a duration, the difference between two dates or times.
1336+
datetime.datetime : Python datetime.datetime object.
1337+
13191338
Notes
13201339
-----
13211340
There are essentially three calling conventions for the constructor. The

pandas/core/frame.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12065,7 +12065,6 @@ def var(
1206512065
) -> Series | Any: ...
1206612066

1206712067
@deprecate_nonkeyword_arguments(version="3.0", allowed_args=["self"], name="var")
12068-
@doc(make_doc("var", ndim=2))
1206912068
def var(
1207012069
self,
1207112070
axis: Axis | None = 0,
@@ -12074,6 +12073,75 @@ def var(
1207412073
numeric_only: bool = False,
1207512074
**kwargs,
1207612075
) -> Series | Any:
12076+
"""
12077+
Return unbiased variance over requested axis.
12078+
12079+
Normalized by N-1 by default. This can be changed using the ddof argument.
12080+
12081+
Parameters
12082+
----------
12083+
axis : {index (0), columns (1)}
12084+
For `Series` this parameter is unused and defaults to 0.
12085+
12086+
.. warning::
12087+
12088+
The behavior of DataFrame.var with ``axis=None`` is deprecated,
12089+
in a future version this will reduce over both axes and return a scalar
12090+
To retain the old behavior, pass axis=0 (or do not pass axis).
12091+
12092+
skipna : bool, default True
12093+
Exclude NA/null values. If an entire row/column is NA, the result
12094+
will be NA.
12095+
ddof : int, default 1
12096+
Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
12097+
where N represents the number of elements.
12098+
numeric_only : bool, default False
12099+
Include only float, int, boolean columns. Not implemented for Series.
12100+
**kwargs :
12101+
Additional keywords passed.
12102+
12103+
Returns
12104+
-------
12105+
Series or scalaer
12106+
Unbiased variance over requested axis.
12107+
12108+
See Also
12109+
--------
12110+
numpy.var : Equivalent function in NumPy.
12111+
Series.var : Return unbiased variance over Series values.
12112+
Series.std : Return standard deviation over Series values.
12113+
DataFrame.std : Return standard deviation of the values over
12114+
the requested axis.
12115+
12116+
Examples
12117+
--------
12118+
>>> df = pd.DataFrame(
12119+
... {
12120+
... "person_id": [0, 1, 2, 3],
12121+
... "age": [21, 25, 62, 43],
12122+
... "height": [1.61, 1.87, 1.49, 2.01],
12123+
... }
12124+
... ).set_index("person_id")
12125+
>>> df
12126+
age height
12127+
person_id
12128+
0 21 1.61
12129+
1 25 1.87
12130+
2 62 1.49
12131+
3 43 2.01
12132+
12133+
>>> df.var()
12134+
age 352.916667
12135+
height 0.056367
12136+
dtype: float64
12137+
12138+
Alternatively, ``ddof=0`` can be set to normalize by N instead of N-1:
12139+
12140+
>>> df.var(ddof=0)
12141+
age 264.687500
12142+
height 0.042275
12143+
dtype: float64
12144+
"""
1207712145
result = super().var(
1207812146
axis=axis, skipna=skipna, ddof=ddof, numeric_only=numeric_only, **kwargs
1207912147
)

pandas/core/indexes/base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,23 @@ def _get_default_index_names(
17991799
return names
18001800

18011801
def _get_names(self) -> FrozenList:
1802+
"""
1803+
Get names on index.
1804+
1805+
See Also
1806+
--------
1807+
Index.name : Return Index or MultiIndex name.
1808+
1809+
Examples
1810+
--------
1811+
>>> idx = pd.Index([1, 2, 3], name="x")
1812+
>>> idx.names
1813+
FrozenList(['x'])
1814+
1815+
>>> idx = s = pd.Index([1, 2, 3], name=("x", "y"))
1816+
>>> idx.names
1817+
FrozenList([('x', 'y')])
1818+
"""
18021819
return FrozenList((self.name,))
18031820

18041821
def _set_names(self, values, *, level=None) -> None:

0 commit comments

Comments
 (0)