Skip to content

Commit f386f6a

Browse files
Merge branch 'main' into fix/as_index_false_returns_multiindex
2 parents 52fb291 + 23dd1f1 commit f386f6a

29 files changed

+322
-121
lines changed

ci/code_checks.sh

+4-38
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8080
-i "pandas.CategoricalIndex.codes SA01" \
8181
-i "pandas.CategoricalIndex.ordered SA01" \
8282
-i "pandas.DataFrame.__dataframe__ SA01" \
83-
-i "pandas.DataFrame.__iter__ SA01" \
8483
-i "pandas.DataFrame.at_time PR01" \
85-
-i "pandas.DataFrame.columns SA01" \
86-
-i "pandas.DataFrame.droplevel SA01" \
8784
-i "pandas.DataFrame.hist RT03" \
8885
-i "pandas.DataFrame.infer_objects RT03" \
8986
-i "pandas.DataFrame.kurt RT03,SA01" \
@@ -93,7 +90,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
9390
-i "pandas.DataFrame.median RT03,SA01" \
9491
-i "pandas.DataFrame.min RT03" \
9592
-i "pandas.DataFrame.plot PR02,SA01" \
96-
-i "pandas.DataFrame.pop SA01" \
9793
-i "pandas.DataFrame.prod RT03" \
9894
-i "pandas.DataFrame.product RT03" \
9995
-i "pandas.DataFrame.reorder_levels SA01" \
@@ -103,71 +99,51 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
10399
-i "pandas.DataFrame.std PR01,RT03,SA01" \
104100
-i "pandas.DataFrame.sum RT03" \
105101
-i "pandas.DataFrame.swaplevel SA01" \
106-
-i "pandas.DataFrame.to_feather SA01" \
107102
-i "pandas.DataFrame.to_markdown SA01" \
108103
-i "pandas.DataFrame.to_parquet RT03" \
109104
-i "pandas.DataFrame.var PR01,RT03,SA01" \
110-
-i "pandas.DatetimeIndex.ceil SA01" \
111-
-i "pandas.DatetimeIndex.date SA01" \
112105
-i "pandas.DatetimeIndex.day_of_year SA01" \
113106
-i "pandas.DatetimeIndex.dayofyear SA01" \
114-
-i "pandas.DatetimeIndex.floor SA01" \
115107
-i "pandas.DatetimeIndex.freqstr SA01" \
116108
-i "pandas.DatetimeIndex.indexer_at_time PR01,RT03" \
117109
-i "pandas.DatetimeIndex.indexer_between_time RT03" \
118110
-i "pandas.DatetimeIndex.inferred_freq SA01" \
119111
-i "pandas.DatetimeIndex.is_leap_year SA01" \
120-
-i "pandas.DatetimeIndex.quarter SA01" \
121-
-i "pandas.DatetimeIndex.round SA01" \
122-
-i "pandas.DatetimeIndex.snap PR01,RT03,SA01" \
112+
-i "pandas.DatetimeIndex.snap PR01,RT03" \
123113
-i "pandas.DatetimeIndex.std PR01,RT03" \
124-
-i "pandas.DatetimeIndex.time SA01" \
125-
-i "pandas.DatetimeIndex.timetz SA01" \
126114
-i "pandas.DatetimeIndex.to_period RT03" \
127115
-i "pandas.DatetimeIndex.to_pydatetime RT03,SA01" \
128-
-i "pandas.DatetimeIndex.tz SA01" \
129116
-i "pandas.DatetimeIndex.tz_convert RT03" \
130117
-i "pandas.DatetimeTZDtype SA01" \
131118
-i "pandas.DatetimeTZDtype.tz SA01" \
132119
-i "pandas.DatetimeTZDtype.unit SA01" \
133120
-i "pandas.Grouper PR02" \
134-
-i "pandas.HDFStore.info RT03,SA01" \
135-
-i "pandas.HDFStore.keys SA01" \
136-
-i "pandas.HDFStore.put PR01,SA01" \
137-
-i "pandas.HDFStore.select SA01" \
138121
-i "pandas.HDFStore.walk SA01" \
139122
-i "pandas.Index PR07" \
140123
-i "pandas.Index.T SA01" \
141124
-i "pandas.Index.append PR07,RT03,SA01" \
142-
-i "pandas.Index.astype SA01" \
143125
-i "pandas.Index.copy PR07,SA01" \
144126
-i "pandas.Index.difference PR07,RT03,SA01" \
145127
-i "pandas.Index.drop PR07,SA01" \
146128
-i "pandas.Index.drop_duplicates RT03" \
147129
-i "pandas.Index.droplevel RT03,SA01" \
148130
-i "pandas.Index.dropna RT03,SA01" \
149-
-i "pandas.Index.dtype SA01" \
150131
-i "pandas.Index.duplicated RT03" \
151132
-i "pandas.Index.empty GL08" \
152-
-i "pandas.Index.equals SA01" \
153133
-i "pandas.Index.fillna RT03" \
154134
-i "pandas.Index.get_indexer PR07,SA01" \
155135
-i "pandas.Index.get_indexer_for PR01,SA01" \
156136
-i "pandas.Index.get_indexer_non_unique PR07,SA01" \
157137
-i "pandas.Index.get_loc PR07,RT03,SA01" \
158138
-i "pandas.Index.get_slice_bound PR07" \
159-
-i "pandas.Index.hasnans SA01" \
160139
-i "pandas.Index.identical PR01,SA01" \
161140
-i "pandas.Index.inferred_type SA01" \
162141
-i "pandas.Index.insert PR07,RT03,SA01" \
163142
-i "pandas.Index.intersection PR07,RT03,SA01" \
164143
-i "pandas.Index.item SA01" \
165144
-i "pandas.Index.join PR07,RT03,SA01" \
166-
-i "pandas.Index.map SA01" \
167145
-i "pandas.Index.memory_usage RT03" \
168-
-i "pandas.Index.name SA01" \
169146
-i "pandas.Index.names GL08" \
170-
-i "pandas.Index.nbytes SA01" \
171147
-i "pandas.Index.nunique RT03" \
172148
-i "pandas.Index.putmask PR01,RT03" \
173149
-i "pandas.Index.ravel PR01,RT03" \
@@ -287,34 +263,28 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
287263
-i "pandas.Series.cat.reorder_categories PR01,PR02" \
288264
-i "pandas.Series.cat.set_categories PR01,PR02" \
289265
-i "pandas.Series.div PR07" \
290-
-i "pandas.Series.droplevel SA01" \
291266
-i "pandas.Series.dt.as_unit PR01,PR02" \
292-
-i "pandas.Series.dt.ceil PR01,PR02,SA01" \
267+
-i "pandas.Series.dt.ceil PR01,PR02" \
293268
-i "pandas.Series.dt.components SA01" \
294-
-i "pandas.Series.dt.date SA01" \
295269
-i "pandas.Series.dt.day_name PR01,PR02" \
296270
-i "pandas.Series.dt.day_of_year SA01" \
297271
-i "pandas.Series.dt.dayofyear SA01" \
298272
-i "pandas.Series.dt.days SA01" \
299273
-i "pandas.Series.dt.days_in_month SA01" \
300274
-i "pandas.Series.dt.daysinmonth SA01" \
301-
-i "pandas.Series.dt.floor PR01,PR02,SA01" \
275+
-i "pandas.Series.dt.floor PR01,PR02" \
302276
-i "pandas.Series.dt.freq GL08" \
303277
-i "pandas.Series.dt.is_leap_year SA01" \
304278
-i "pandas.Series.dt.microseconds SA01" \
305279
-i "pandas.Series.dt.month_name PR01,PR02" \
306280
-i "pandas.Series.dt.nanoseconds SA01" \
307281
-i "pandas.Series.dt.normalize PR01" \
308-
-i "pandas.Series.dt.quarter SA01" \
309282
-i "pandas.Series.dt.qyear GL08" \
310-
-i "pandas.Series.dt.round PR01,PR02,SA01" \
283+
-i "pandas.Series.dt.round PR01,PR02" \
311284
-i "pandas.Series.dt.seconds SA01" \
312285
-i "pandas.Series.dt.strftime PR01,PR02" \
313-
-i "pandas.Series.dt.time SA01" \
314-
-i "pandas.Series.dt.timetz SA01" \
315286
-i "pandas.Series.dt.to_period PR01,PR02,RT03" \
316287
-i "pandas.Series.dt.total_seconds PR01" \
317-
-i "pandas.Series.dt.tz SA01" \
318288
-i "pandas.Series.dt.tz_convert PR01,PR02,RT03" \
319289
-i "pandas.Series.dt.tz_localize PR01,PR02" \
320290
-i "pandas.Series.dt.unit GL08" \
@@ -344,7 +314,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
344314
-i "pandas.Series.mod PR07" \
345315
-i "pandas.Series.mode SA01" \
346316
-i "pandas.Series.mul PR07" \
347-
-i "pandas.Series.nbytes SA01" \
348317
-i "pandas.Series.ne PR07,SA01" \
349318
-i "pandas.Series.nunique RT03" \
350319
-i "pandas.Series.pad PR01,SA01" \
@@ -432,14 +401,11 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
432401
-i "pandas.Timedelta.total_seconds SA01" \
433402
-i "pandas.Timedelta.view SA01" \
434403
-i "pandas.TimedeltaIndex.as_unit RT03,SA01" \
435-
-i "pandas.TimedeltaIndex.ceil SA01" \
436404
-i "pandas.TimedeltaIndex.components SA01" \
437405
-i "pandas.TimedeltaIndex.days SA01" \
438-
-i "pandas.TimedeltaIndex.floor SA01" \
439406
-i "pandas.TimedeltaIndex.inferred_freq SA01" \
440407
-i "pandas.TimedeltaIndex.microseconds SA01" \
441408
-i "pandas.TimedeltaIndex.nanoseconds SA01" \
442-
-i "pandas.TimedeltaIndex.round SA01" \
443409
-i "pandas.TimedeltaIndex.seconds SA01" \
444410
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
445411
-i "pandas.Timestamp PR07,SA01" \

doc/source/development/community.rst

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ The pandas mailing list `[email protected] <mailto://pandas-dev@python
100100
conversations and to engage people in the wider community who might not
101101
be active on the issue tracker but we would like to include in discussions.
102102

103+
Join the mailing list and view the archives `here <https://mail.python.org/mailman/listinfo/pandas-dev>`_.
104+
103105
.. _community.slack:
104106

105107
Community slack

doc/source/user_guide/style.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@
19081908
"- Provide an API that is pleasing to use interactively and is \"good enough\" for many tasks\n",
19091909
"- Provide the foundations for dedicated libraries to build on\n",
19101910
"\n",
1911-
"If you build a great library on top of this, let us know and we'll [link](https://pandas.pydata.org/pandas-docs/stable/ecosystem.html) to it.\n",
1911+
"If you build a great library on top of this, let us know and we'll [link](https://pandas.pydata.org/community/ecosystem.html) to it.\n",
19121912
"\n",
19131913
"### Subclassing\n",
19141914
"\n",

doc/source/whatsnew/v3.0.0.rst

+3
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ Other Deprecations
199199
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.all`, :meth:`DataFrame.min`, :meth:`DataFrame.max`, :meth:`DataFrame.sum`, :meth:`DataFrame.prod`, :meth:`DataFrame.mean`, :meth:`DataFrame.median`, :meth:`DataFrame.sem`, :meth:`DataFrame.var`, :meth:`DataFrame.std`, :meth:`DataFrame.skew`, :meth:`DataFrame.kurt`, :meth:`Series.all`, :meth:`Series.min`, :meth:`Series.max`, :meth:`Series.sum`, :meth:`Series.prod`, :meth:`Series.mean`, :meth:`Series.median`, :meth:`Series.sem`, :meth:`Series.var`, :meth:`Series.std`, :meth:`Series.skew`, and :meth:`Series.kurt`. (:issue:`57087`)
200200
- Deprecated allowing non-keyword arguments in :meth:`Series.to_markdown` except ``buf``. (:issue:`57280`)
201201
- Deprecated allowing non-keyword arguments in :meth:`Series.to_string` except ``buf``. (:issue:`57280`)
202+
- Deprecated behavior of :meth:`Series.dt.to_pytimedelta`, in a future version this will return a :class:`Series` containing python ``datetime.timedelta`` objects instead of an ``ndarray`` of timedelta; this matches the behavior of other :meth:`Series.dt` properties. (:issue:`57463`)
202203
- Deprecated using ``epoch`` date format in :meth:`DataFrame.to_json` and :meth:`Series.to_json`, use ``iso`` instead. (:issue:`57063`)
203204
-
204205

@@ -360,6 +361,7 @@ Datetimelike
360361
- Bug in :func:`date_range` where the last valid timestamp would sometimes not be produced (:issue:`56134`)
361362
- Bug in :func:`date_range` where using a negative frequency value would not include all points between the start and end values (:issue:`56382`)
362363
- Bug in :func:`tseries.api.guess_datetime_format` would fail to infer time format when "%Y" == "%H%M" (:issue:`57452`)
364+
- Bug in setting scalar values with mismatched resolution into arrays with non-nanosecond ``datetime64``, ``timedelta64`` or :class:`DatetimeTZDtype` incorrectly truncating those scalars (:issue:`56410`)
363365

364366
Timedelta
365367
^^^^^^^^^
@@ -458,6 +460,7 @@ Other
458460
- Bug in :class:`DataFrame` when passing a ``dict`` with a NA scalar and ``columns`` that would always return ``np.nan`` (:issue:`57205`)
459461
- Bug in :func:`unique` on :class:`Index` not always returning :class:`Index` (:issue:`57043`)
460462
- Bug in :meth:`DataFrame.eval` and :meth:`DataFrame.query` which caused an exception when using NumPy attributes via ``@`` notation, e.g., ``df.eval("@np.floor(a)")``. (:issue:`58041`)
463+
- Bug in :meth:`DataFrame.eval` and :meth:`DataFrame.query` which did not allow to use ``tan`` function. (:issue:`55091`)
461464
- Bug in :meth:`DataFrame.sort_index` when passing ``axis="columns"`` and ``ignore_index=True`` and ``ascending=False`` not returning a :class:`RangeIndex` columns (:issue:`57293`)
462465
- Bug in :meth:`DataFrame.transform` that was returning the wrong order unless the index was monotonically increasing. (:issue:`57069`)
463466
- Bug in :meth:`DataFrame.where` where using a non-bool type array in the function would return a ``ValueError`` instead of a ``TypeError`` (:issue:`56330`)

pandas/_libs/lib.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def has_infs(const floating[:] arr) -> bool:
477477

478478
@cython.boundscheck(False)
479479
@cython.wraparound(False)
480-
def has_only_ints_or_nan(floating[:] arr) -> bool:
480+
def has_only_ints_or_nan(const floating[:] arr) -> bool:
481481
cdef:
482482
floating val
483483
intp_t i
@@ -631,7 +631,7 @@ ctypedef fused int6432_t:
631631

632632
@cython.wraparound(False)
633633
@cython.boundscheck(False)
634-
def is_range_indexer(ndarray[int6432_t, ndim=1] left, Py_ssize_t n) -> bool:
634+
def is_range_indexer(const int6432_t[:] left, Py_ssize_t n) -> bool:
635635
"""
636636
Perform an element by element comparison on 1-d integer arrays, meant for indexer
637637
comparisons
@@ -652,7 +652,7 @@ def is_range_indexer(ndarray[int6432_t, ndim=1] left, Py_ssize_t n) -> bool:
652652

653653
@cython.wraparound(False)
654654
@cython.boundscheck(False)
655-
def is_sequence_range(ndarray[int6432_t, ndim=1] sequence, int64_t step) -> bool:
655+
def is_sequence_range(const int6432_t[:] sequence, int64_t step) -> bool:
656656
"""
657657
Check if sequence is equivalent to a range with the specified step.
658658
"""

pandas/_libs/reshape.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ from pandas._libs.lib cimport c_is_list_like
1919

2020
@cython.wraparound(False)
2121
@cython.boundscheck(False)
22-
def unstack(numeric_object_t[:, :] values, const uint8_t[:] mask,
22+
def unstack(const numeric_object_t[:, :] values, const uint8_t[:] mask,
2323
Py_ssize_t stride, Py_ssize_t length, Py_ssize_t width,
2424
numeric_object_t[:, :] new_values, uint8_t[:, :] new_mask) -> None:
2525
"""
@@ -80,7 +80,7 @@ def unstack(numeric_object_t[:, :] values, const uint8_t[:] mask,
8080

8181
@cython.wraparound(False)
8282
@cython.boundscheck(False)
83-
def explode(ndarray[object] values):
83+
def explode(object[:] values):
8484
"""
8585
transform array list-likes to long form
8686
preserve non-list entries

pandas/conftest.py

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def pytest_collection_modifyitems(items, config) -> None:
157157
("SeriesGroupBy.fillna", "SeriesGroupBy.fillna is deprecated"),
158158
("SeriesGroupBy.idxmin", "The behavior of Series.idxmin"),
159159
("SeriesGroupBy.idxmax", "The behavior of Series.idxmax"),
160+
("to_pytimedelta", "The behavior of TimedeltaProperties.to_pytimedelta"),
160161
# Docstring divides by zero to show behavior difference
161162
("missing.mask_zero_div_zero", "divide by zero encountered"),
162163
(

pandas/core/arrays/datetimelike.py

+5
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,11 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
18251825
------
18261826
ValueError if the `freq` cannot be converted.
18271827
1828+
See Also
1829+
--------
1830+
DatetimeIndex.floor : Perform floor operation on the data to the specified `freq`.
1831+
DatetimeIndex.snap : Snap time stamps to nearest occurring frequency.
1832+
18281833
Notes
18291834
-----
18301835
If the timestamps have a timezone, {op}ing will take place relative to the

pandas/core/arrays/datetimes.py

+36-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def _unbox_scalar(self, value) -> np.datetime64:
539539
if value is NaT:
540540
return np.datetime64(value._value, self.unit)
541541
else:
542-
return value.as_unit(self.unit).asm8
542+
return value.as_unit(self.unit, round_ok=False).asm8
543543

544544
def _scalar_from_string(self, value) -> Timestamp | NaTType:
545545
return Timestamp(value, tz=self.tz)
@@ -593,6 +593,13 @@ def tz(self) -> tzinfo | None:
593593
datetime.tzinfo, pytz.tzinfo.BaseTZInfo, dateutil.tz.tz.tzfile, or None
594594
Returns None when the array is tz-naive.
595595
596+
See Also
597+
--------
598+
DatetimeIndex.tz_localize : Localize tz-naive DatetimeIndex to a
599+
given time zone, or remove timezone from a tz-aware DatetimeIndex.
600+
DatetimeIndex.tz_convert : Convert tz-aware DatetimeIndex from
601+
one time zone to another.
602+
596603
Examples
597604
--------
598605
For Series:
@@ -1391,6 +1398,14 @@ def time(self) -> npt.NDArray[np.object_]:
13911398
13921399
The time part of the Timestamps.
13931400
1401+
See Also
1402+
--------
1403+
DatetimeIndex.timetz : Returns numpy array of :class:`datetime.time`
1404+
objects with timezones. The time part of the Timestamps.
1405+
DatetimeIndex.date : Returns numpy array of python :class:`datetime.date`
1406+
objects. Namely, the date part of Timestamps without time and timezone
1407+
information.
1408+
13941409
Examples
13951410
--------
13961411
For Series:
@@ -1428,6 +1443,12 @@ def timetz(self) -> npt.NDArray[np.object_]:
14281443
14291444
The time part of the Timestamps.
14301445
1446+
See Also
1447+
--------
1448+
DatetimeIndex.time : Returns numpy array of :class:`datetime.time` objects.
1449+
The time part of the Timestamps.
1450+
DatetimeIndex.tz : Return the timezone.
1451+
14311452
Examples
14321453
--------
14331454
For Series:
@@ -1462,6 +1483,14 @@ def date(self) -> npt.NDArray[np.object_]:
14621483
Namely, the date part of Timestamps without time and
14631484
timezone information.
14641485
1486+
See Also
1487+
--------
1488+
DatetimeIndex.time : Returns numpy array of :class:`datetime.time` objects.
1489+
The time part of the Timestamps.
1490+
DatetimeIndex.year : The year of the datetime.
1491+
DatetimeIndex.month : The month as January=1, December=12.
1492+
DatetimeIndex.day : The day of the datetime.
1493+
14651494
Examples
14661495
--------
14671496
For Series:
@@ -1836,6 +1865,12 @@ def isocalendar(self) -> DataFrame:
18361865
"""
18371866
The quarter of the date.
18381867
1868+
See Also
1869+
--------
1870+
DatetimeIndex.snap : Snap time stamps to nearest occurring frequency.
1871+
DatetimeIndex.time : Returns numpy array of datetime.time objects.
1872+
The time part of the Timestamps.
1873+
18391874
Examples
18401875
--------
18411876
For Series:

pandas/core/arrays/timedeltas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def _unbox_scalar(self, value) -> np.timedelta64:
322322
if value is NaT:
323323
return np.timedelta64(value._value, self.unit)
324324
else:
325-
return value.as_unit(self.unit).asm8
325+
return value.as_unit(self.unit, round_ok=False).asm8
326326

327327
def _scalar_from_string(self, value) -> Timedelta | NaTType:
328328
return Timedelta(value)

pandas/core/base.py

+5
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ def nbytes(self) -> int:
419419
"""
420420
Return the number of bytes in the underlying data.
421421
422+
See Also
423+
--------
424+
Series.ndim : Number of dimensions of the underlying data.
425+
Series.size : Return the number of elements in the underlying data.
426+
422427
Examples
423428
--------
424429
For Series:

pandas/core/computation/ops.py

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
_unary_math_ops = (
4646
"sin",
4747
"cos",
48+
"tan",
4849
"exp",
4950
"log",
5051
"expm1",

0 commit comments

Comments
 (0)