Skip to content

Commit 3f2d1e7

Browse files
authored
Merge branch 'main' into doc-dataframe-groupby-prod
2 parents e10c70a + 360597c commit 3f2d1e7

File tree

10 files changed

+240
-216
lines changed

10 files changed

+240
-216
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -133,34 +133,17 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
133133
-i "pandas.Series.dt.tz_convert PR01,PR02" \
134134
-i "pandas.Series.dt.tz_localize PR01,PR02" \
135135
-i "pandas.Series.dt.unit GL08" \
136-
-i "pandas.Series.gt SA01" \
137-
-i "pandas.Series.list.__getitem__ SA01" \
138-
-i "pandas.Series.list.flatten SA01" \
139-
-i "pandas.Series.list.len SA01" \
140-
-i "pandas.Series.lt SA01" \
141-
-i "pandas.Series.ne SA01" \
142136
-i "pandas.Series.pad PR01,SA01" \
143-
-i "pandas.Series.pop SA01" \
144-
-i "pandas.Series.prod RT03" \
145-
-i "pandas.Series.product RT03" \
146-
-i "pandas.Series.reorder_levels RT03,SA01" \
147137
-i "pandas.Series.sem PR01,RT03,SA01" \
148138
-i "pandas.Series.sparse PR01,SA01" \
149-
-i "pandas.Series.sparse.density SA01" \
150139
-i "pandas.Series.sparse.fill_value SA01" \
151140
-i "pandas.Series.sparse.from_coo PR07,SA01" \
152141
-i "pandas.Series.sparse.npoints SA01" \
153142
-i "pandas.Series.sparse.sp_values SA01" \
154143
-i "pandas.Series.sparse.to_coo PR07,RT03,SA01" \
155144
-i "pandas.Series.std PR01,RT03,SA01" \
156-
-i "pandas.Series.str.match RT03" \
157-
-i "pandas.Series.str.normalize RT03,SA01" \
158-
-i "pandas.Series.str.repeat SA01" \
159-
-i "pandas.Series.str.replace SA01" \
160145
-i "pandas.Series.str.wrap RT03,SA01" \
161146
-i "pandas.Series.str.zfill RT03" \
162-
-i "pandas.Series.struct.dtypes SA01" \
163-
-i "pandas.Series.to_markdown SA01" \
164147
-i "pandas.Timedelta.asm8 SA01" \
165148
-i "pandas.Timedelta.ceil SA01" \
166149
-i "pandas.Timedelta.components SA01" \
@@ -179,7 +162,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
179162
-i "pandas.TimedeltaIndex.nanoseconds SA01" \
180163
-i "pandas.TimedeltaIndex.seconds SA01" \
181164
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
182-
-i "pandas.Timestamp.day GL08" \
183165
-i "pandas.Timestamp.fold GL08" \
184166
-i "pandas.Timestamp.hour GL08" \
185167
-i "pandas.Timestamp.max PR02" \
@@ -193,12 +175,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
193175
-i "pandas.Timestamp.tzinfo GL08" \
194176
-i "pandas.Timestamp.value GL08" \
195177
-i "pandas.Timestamp.year GL08" \
196-
-i "pandas.api.extensions.ExtensionArray._pad_or_backfill PR01,RT03,SA01" \
197-
-i "pandas.api.extensions.ExtensionArray._reduce RT03,SA01" \
198-
-i "pandas.api.extensions.ExtensionArray._values_for_factorize SA01" \
199-
-i "pandas.api.extensions.ExtensionArray.astype SA01" \
200-
-i "pandas.api.extensions.ExtensionArray.dropna RT03,SA01" \
201-
-i "pandas.api.extensions.ExtensionArray.dtype SA01" \
202178
-i "pandas.api.extensions.ExtensionArray.duplicated RT03,SA01" \
203179
-i "pandas.api.extensions.ExtensionArray.fillna SA01" \
204180
-i "pandas.api.extensions.ExtensionArray.insert PR07,RT03,SA01" \

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,29 @@ cdef class _Timestamp(ABCTimestamp):
961961
"""
962962
return ((self.month - 1) // 3) + 1
963963
964+
@property
965+
def day(self) -> int:
966+
"""
967+
Return the day of the Timestamp.
968+
969+
Returns
970+
-------
971+
int
972+
The day of the Timestamp.
973+
974+
See Also
975+
--------
976+
Timestamp.week : Return the week number of the year.
977+
Timestamp.weekday : Return the day of the week.
978+
979+
Examples
980+
--------
981+
>>> ts = pd.Timestamp("2024-08-31 16:16:30")
982+
>>> ts.day
983+
31
984+
"""
985+
return super().day
986+
964987
@property
965988
def week(self) -> int:
966989
"""

pandas/core/arrays/arrow/accessors.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ def len(self) -> Series:
9292
pandas.Series
9393
The length of each list.
9494
95+
See Also
96+
--------
97+
str.len : Python built-in function returning the length of an object.
98+
Series.size : Returns the length of the Series.
99+
StringMethods.len : Compute the length of each element in the Series/Index.
100+
95101
Examples
96102
--------
97103
>>> import pyarrow as pa
@@ -128,6 +134,10 @@ def __getitem__(self, key: int | slice) -> Series:
128134
pandas.Series
129135
The list at requested index.
130136
137+
See Also
138+
--------
139+
ListAccessor.flatten : Flatten list values.
140+
131141
Examples
132142
--------
133143
>>> import pyarrow as pa
@@ -187,6 +197,10 @@ def flatten(self) -> Series:
187197
pandas.Series
188198
The data from all lists in the series flattened.
189199
200+
See Also
201+
--------
202+
ListAccessor.__getitem__ : Index or slice values in the Series.
203+
190204
Examples
191205
--------
192206
>>> import pyarrow as pa
@@ -244,6 +258,10 @@ def dtypes(self) -> Series:
244258
pandas.Series
245259
The data type of each child field.
246260
261+
See Also
262+
--------
263+
Series.dtype: Return the dtype object of the underlying data.
264+
247265
Examples
248266
--------
249267
>>> import pyarrow as pa

pandas/core/arrays/base.py

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,14 @@ def dtype(self) -> ExtensionDtype:
608608
"""
609609
An instance of ExtensionDtype.
610610
611+
See Also
612+
--------
613+
api.extensions.ExtensionDtype : Base class for extension dtypes.
614+
api.extensions.ExtensionArray : Base class for extension array types.
615+
api.extensions.ExtensionArray.dtype : The dtype of an ExtensionArray.
616+
Series.dtype : The dtype of a Series.
617+
DataFrame.dtype : The dtype of a DataFrame.
618+
611619
Examples
612620
--------
613621
>>> pd.array([1, 2, 3]).dtype
@@ -713,6 +721,16 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike:
713721
An ``ExtensionArray`` if ``dtype`` is ``ExtensionDtype``,
714722
otherwise a Numpy ndarray with ``dtype`` for its dtype.
715723
724+
See Also
725+
--------
726+
Series.astype : Cast a Series to a different dtype.
727+
DataFrame.astype : Cast a DataFrame to a different dtype.
728+
api.extensions.ExtensionArray : Base class for ExtensionArray objects.
729+
core.arrays.DatetimeArray._from_sequence : Create a DatetimeArray from a
730+
sequence.
731+
core.arrays.TimedeltaArray._from_sequence : Create a TimedeltaArray from
732+
a sequence.
733+
716734
Examples
717735
--------
718736
>>> arr = pd.array([1, 2, 3])
@@ -1032,6 +1050,12 @@ def _pad_or_backfill(
10321050
maximum number of entries along the entire axis where NaNs will be
10331051
filled.
10341052
1053+
limit_area : {'inside', 'outside'} or None, default None
1054+
Specifies which area to limit filling.
1055+
- 'inside': Limit the filling to the area within the gaps.
1056+
- 'outside': Limit the filling to the area outside the gaps.
1057+
If `None`, no limitation is applied.
1058+
10351059
copy : bool, default True
10361060
Whether to make a copy of the data before filling. If False, then
10371061
the original should be modified and no new memory should be allocated.
@@ -1043,6 +1067,16 @@ def _pad_or_backfill(
10431067
Returns
10441068
-------
10451069
Same type as self
1070+
The filled array with the same type as the original.
1071+
1072+
See Also
1073+
--------
1074+
Series.ffill : Forward fill missing values.
1075+
Series.bfill : Backward fill missing values.
1076+
DataFrame.ffill : Forward fill missing values in DataFrame.
1077+
DataFrame.bfill : Backward fill missing values in DataFrame.
1078+
api.types.isna : Check for missing values.
1079+
api.types.isnull : Check for missing values.
10461080
10471081
Examples
10481082
--------
@@ -1149,6 +1183,16 @@ def dropna(self) -> Self:
11491183
11501184
Returns
11511185
-------
1186+
Self
1187+
An ExtensionArray of the same type as the original but with all
1188+
NA values removed.
1189+
1190+
See Also
1191+
--------
1192+
Series.dropna : Remove missing values from a Series.
1193+
DataFrame.dropna : Remove missing values from a DataFrame.
1194+
api.extensions.ExtensionArray.isna : Check for missing values in
1195+
an ExtensionArray.
11521196
11531197
Examples
11541198
--------
@@ -1423,6 +1467,10 @@ def _values_for_factorize(self) -> tuple[np.ndarray, Any]:
14231467
`-1` and not included in `uniques`. By default,
14241468
``np.nan`` is used.
14251469
1470+
See Also
1471+
--------
1472+
util.hash_pandas_object : Hash the pandas object.
1473+
14261474
Notes
14271475
-----
14281476
The values returned by this method are also used in
@@ -1988,16 +2036,43 @@ def _reduce(
19882036
19892037
Returns
19902038
-------
1991-
scalar
2039+
scalar or ndarray:
2040+
The result of the reduction operation. The type of the result
2041+
depends on `keepdims`:
2042+
- If `keepdims` is `False`, a scalar value is returned.
2043+
- If `keepdims` is `True`, the result is wrapped in a numpy array with
2044+
a single element.
19922045
19932046
Raises
19942047
------
19952048
TypeError : subclass does not define operations
19962049
2050+
See Also
2051+
--------
2052+
Series.min : Return the minimum value.
2053+
Series.max : Return the maximum value.
2054+
Series.sum : Return the sum of values.
2055+
Series.mean : Return the mean of values.
2056+
Series.median : Return the median of values.
2057+
Series.std : Return the standard deviation.
2058+
Series.var : Return the variance.
2059+
Series.prod : Return the product of values.
2060+
Series.sem : Return the standard error of the mean.
2061+
Series.kurt : Return the kurtosis.
2062+
Series.skew : Return the skewness.
2063+
19972064
Examples
19982065
--------
19992066
>>> pd.array([1, 2, 3])._reduce("min")
20002067
1
2068+
>>> pd.array([1, 2, 3])._reduce("max")
2069+
3
2070+
>>> pd.array([1, 2, 3])._reduce("sum")
2071+
6
2072+
>>> pd.array([1, 2, 3])._reduce("mean")
2073+
2.0
2074+
>>> pd.array([1, 2, 3])._reduce("median")
2075+
2.0
20012076
"""
20022077
meth = getattr(self, name, None)
20032078
if meth is None:

pandas/core/arrays/sparse/array.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@ def density(self) -> float:
671671
"""
672672
The percent of non- ``fill_value`` points, as decimal.
673673
674+
See Also
675+
--------
676+
DataFrame.sparse.from_spmatrix : Create a new DataFrame from a
677+
scipy sparse matrix.
678+
674679
Examples
675680
--------
676681
>>> from pandas.arrays import SparseArray

pandas/core/generic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11815,6 +11815,8 @@ def last_valid_index(self) -> Hashable:
1181511815
Returns
1181611816
-------
1181711817
{name1} or scalar\
11818+
11819+
Value containing the calculation referenced in the description.\
1181811820
{see_also}\
1181911821
{examples}
1182011822
"""

pandas/core/ops/docstrings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def make_flex_doc(op_name: str, typ: str) -> str:
376376
"ne": {
377377
"op": "!=",
378378
"desc": "Not equal to",
379-
"reverse": None,
379+
"reverse": "eq",
380380
"series_examples": _ne_example_SERIES,
381381
"series_returns": _returns_series,
382382
},
@@ -397,14 +397,14 @@ def make_flex_doc(op_name: str, typ: str) -> str:
397397
"gt": {
398398
"op": ">",
399399
"desc": "Greater than",
400-
"reverse": None,
400+
"reverse": "lt",
401401
"series_examples": _gt_example_SERIES,
402402
"series_returns": _returns_series,
403403
},
404404
"ge": {
405405
"op": ">=",
406406
"desc": "Greater than or equal to",
407-
"reverse": None,
407+
"reverse": "le",
408408
"series_examples": _ge_example_SERIES,
409409
"series_returns": _returns_series,
410410
},

pandas/core/series.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,11 @@ def to_markdown(
16171617
str
16181618
{klass} in Markdown-friendly format.
16191619
1620+
See Also
1621+
--------
1622+
Series.to_frame : Rrite a text representation of object to the system clipboard.
1623+
Series.to_latex : Render Series to LaTeX-formatted table.
1624+
16201625
Notes
16211626
-----
16221627
Requires the `tabulate <https://pypi.org/project/tabulate>`_ package.
@@ -2619,6 +2624,13 @@ def corr(
26192624
>>> s2 = pd.Series([1, 2, 3], index=[2, 1, 0])
26202625
>>> s1.corr(s2)
26212626
-1.0
2627+
2628+
If the input is a constant array, the correlation is not defined in this case,
2629+
and ``np.nan`` is returned.
2630+
2631+
>>> s1 = pd.Series([0.45, 0.45])
2632+
>>> s1.corr(s1)
2633+
nan
26222634
""" # noqa: E501
26232635
this, other = self.align(other, join="inner")
26242636
if len(this) == 0:
@@ -4093,7 +4105,13 @@ def reorder_levels(self, order: Sequence[Level]) -> Series:
40934105
40944106
Returns
40954107
-------
4096-
type of caller (new object)
4108+
Series
4109+
Type of caller with index as MultiIndex (new object).
4110+
4111+
See Also
4112+
--------
4113+
DataFrame.reorder_levels : Rearrange index or column levels using
4114+
input ``order``.
40974115
40984116
Examples
40994117
--------
@@ -5048,6 +5066,11 @@ def pop(self, item: Hashable) -> Any:
50485066
scalar
50495067
Value that is popped from series.
50505068
5069+
See Also
5070+
--------
5071+
Series.drop: Drop specified values from Series.
5072+
Series.drop_duplicates: Return Series with duplicate values removed.
5073+
50515074
Examples
50525075
--------
50535076
>>> ser = pd.Series([1, 2, 3])

0 commit comments

Comments
 (0)