Skip to content

Commit e58fc06

Browse files
committed
Merge remote-tracking branch 'upstream/main' into eval_div
2 parents 8d2f4cc + e78ebd3 commit e58fc06

File tree

12 files changed

+268
-54
lines changed

12 files changed

+268
-54
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,15 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
100100
-i "pandas.Timedelta.max PR02" \
101101
-i "pandas.Timedelta.min PR02" \
102102
-i "pandas.Timedelta.resolution PR02" \
103-
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
104103
-i "pandas.Timestamp.max PR02" \
105104
-i "pandas.Timestamp.min PR02" \
106105
-i "pandas.Timestamp.nanosecond GL08" \
107106
-i "pandas.Timestamp.resolution PR02" \
108107
-i "pandas.Timestamp.tzinfo GL08" \
109108
-i "pandas.Timestamp.year GL08" \
110-
-i "pandas.api.types.is_dict_like PR07,SA01" \
111-
-i "pandas.api.types.is_file_like PR07,SA01" \
112109
-i "pandas.api.types.is_float PR01,SA01" \
113-
-i "pandas.api.types.is_hashable PR01,RT03,SA01" \
114110
-i "pandas.api.types.is_integer PR01,SA01" \
115111
-i "pandas.api.types.is_iterator PR07,SA01" \
116-
-i "pandas.api.types.is_named_tuple PR07,SA01" \
117-
-i "pandas.api.types.is_re PR07,SA01" \
118112
-i "pandas.api.types.is_re_compilable PR07,SA01" \
119113
-i "pandas.api.types.pandas_dtype PR07,RT03,SA01" \
120114
-i "pandas.arrays.ArrowExtensionArray PR07,SA01" \
@@ -165,7 +159,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
165159
-i "pandas.errors.CSSWarning SA01" \
166160
-i "pandas.errors.CategoricalConversionWarning SA01" \
167161
-i "pandas.errors.ChainedAssignmentError SA01" \
168-
-i "pandas.errors.ClosedFileError SA01" \
169162
-i "pandas.errors.DataError SA01" \
170163
-i "pandas.errors.DuplicateLabelError SA01" \
171164
-i "pandas.errors.IntCastingNaNError SA01" \
@@ -175,7 +168,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
175168
-i "pandas.errors.NumExprClobberingError SA01" \
176169
-i "pandas.errors.NumbaUtilError SA01" \
177170
-i "pandas.errors.OptionError SA01" \
178-
-i "pandas.errors.OutOfBoundsDatetime SA01" \
179171
-i "pandas.errors.OutOfBoundsTimedelta SA01" \
180172
-i "pandas.errors.PerformanceWarning SA01" \
181173
-i "pandas.errors.PossibleDataLossError SA01" \

doc/source/getting_started/intro_tutorials/08_combine_dataframes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ Add the parameters' full description and name, provided by the parameters metada
271271
272272
Compared to the previous example, there is no common column name.
273273
However, the ``parameter`` column in the ``air_quality`` table and the
274-
``id`` column in the ``air_quality_parameters_name`` both provide the
274+
``id`` column in the ``air_quality_parameters`` table both provide the
275275
measured variable in a common format. The ``left_on`` and ``right_on``
276276
arguments are used here (instead of just ``on``) to make the link
277277
between the two tables.

doc/source/user_guide/10min.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ See the indexing documentation :ref:`Indexing and Selecting Data <indexing>` and
177177
Getitem (``[]``)
178178
~~~~~~~~~~~~~~~~
179179

180-
For a :class:`DataFrame`, passing a single label selects a columns and
180+
For a :class:`DataFrame`, passing a single label selects a column and
181181
yields a :class:`Series` equivalent to ``df.A``:
182182

183183
.. ipython:: python

doc/source/user_guide/dsintro.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ index will be pulled out.
8787

8888
**From scalar value**
8989

90-
If ``data`` is a scalar value, an index must be
91-
provided. The value will be repeated to match the length of **index**.
90+
If ``data`` is a scalar value, the value will be repeated to match
91+
the length of **index**. If the **index** is not provided, it defaults
92+
to ``RangeIndex(1)``.
9293

9394
.. ipython:: python
9495

pandas/_libs/src/vendored/ujson/python/JSONtoObj.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ Numeric decoder derived from TCL library
3838

3939
// Licence at LICENSES/ULTRAJSON_LICENSE
4040

41-
#include "pandas/vendored/ujson/lib/ultrajson.h"
41+
// clang-format off
4242
#define PY_SSIZE_T_CLEAN
4343
#include <Python.h>
44+
#include "pandas/vendored/ujson/lib/ultrajson.h"
45+
// clang-format on
4446

4547
static int Object_objectAddKey(void *Py_UNUSED(prv), JSOBJ obj, JSOBJ name,
4648
JSOBJ value) {

pandas/_libs/tslibs/nattype.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ class NaTType(_NaT):
500500
--------
501501
to_timedelta : Convert argument to timedelta.
502502
Timedelta : Represents a duration, the difference between two dates or times.
503+
Timedelta.seconds : Returns the seconds component of the timedelta.
504+
Timedelta.microseconds : Returns the microseconds component of the timedelta.
503505
504506
Examples
505507
--------

pandas/_libs/tslibs/np_datetime.pyx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ class OutOfBoundsDatetime(ValueError):
176176
"""
177177
Raised when the datetime is outside the range that can be represented.
178178
179+
This error occurs when attempting to convert or parse a datetime value
180+
that exceeds the bounds supported by pandas' internal datetime
181+
representation.
182+
183+
See Also
184+
--------
185+
to_datetime : Convert argument to datetime.
186+
Timestamp : Pandas replacement for python ``datetime.datetime`` object.
187+
179188
Examples
180189
--------
181190
>>> pd.to_datetime("08335394550")

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,8 @@ cdef class _Timedelta(timedelta):
11961196
--------
11971197
to_timedelta : Convert argument to timedelta.
11981198
Timedelta : Represents a duration, the difference between two dates or times.
1199+
Timedelta.seconds : Returns the seconds component of the timedelta.
1200+
Timedelta.microseconds : Returns the microseconds component of the timedelta.
11991201

12001202
Examples
12011203
--------
@@ -1493,6 +1495,7 @@ cdef class _Timedelta(timedelta):
14931495
14941496
See Also
14951497
--------
1498+
Timedelta.asm8 : Return a numpy timedelta64 array scalar view.
14961499
numpy.ndarray.view : Returns a view of an array with the same data.
14971500
Timedelta.to_numpy : Converts the Timedelta to a NumPy timedelta64.
14981501
Timedelta.total_seconds : Returns the total duration of the Timedelta

pandas/core/arrays/timedeltas.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,19 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:
790790
Returns
791791
-------
792792
numpy.ndarray
793+
A NumPy ``timedelta64`` object representing the same duration as the
794+
original pandas ``Timedelta`` object. The precision of the resulting
795+
object is in nanoseconds, which is the default
796+
time resolution used by pandas for ``Timedelta`` objects, ensuring
797+
high precision for time-based calculations.
798+
799+
See Also
800+
--------
801+
to_timedelta : Convert argument to timedelta format.
802+
Timedelta : Represents a duration between two dates or times.
803+
DatetimeIndex: Index of datetime64 data.
804+
Timedelta.components : Return a components namedtuple-like
805+
of a single timedelta.
793806
794807
Examples
795808
--------
@@ -800,6 +813,14 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:
800813
>>> tdelta_idx.to_pytimedelta()
801814
array([datetime.timedelta(days=1), datetime.timedelta(days=2),
802815
datetime.timedelta(days=3)], dtype=object)
816+
817+
>>> tidx = pd.TimedeltaIndex(data=["1 days 02:30:45", "3 days 04:15:10"])
818+
>>> tidx
819+
TimedeltaIndex(['1 days 02:30:45', '3 days 04:15:10'],
820+
dtype='timedelta64[ns]', freq=None)
821+
>>> tidx.to_pytimedelta()
822+
array([datetime.timedelta(days=1, seconds=9045),
823+
datetime.timedelta(days=3, seconds=15310)], dtype=object)
803824
"""
804825
return ints_to_pytimedelta(self._ndarray)
805826

pandas/core/dtypes/inference.py

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,24 @@ def is_file_like(obj: object) -> bool:
113113
114114
Parameters
115115
----------
116-
obj : The object to check
116+
obj : object
117+
The object to check for file-like properties.
118+
This can be any Python object, and the function will
119+
check if it has attributes typically associated with
120+
file-like objects (e.g., `read`, `write`, `__iter__`).
117121
118122
Returns
119123
-------
120124
bool
121125
Whether `obj` has file-like properties.
122126
127+
See Also
128+
--------
129+
api.types.is_dict_like : Check if the object is dict-like.
130+
api.types.is_hashable : Return True if hash(obj) will succeed, False otherwise.
131+
api.types.is_named_tuple : Check if the object is a named tuple.
132+
api.types.is_iterator : Check if the object is an iterator.
133+
123134
Examples
124135
--------
125136
>>> import io
@@ -142,13 +153,24 @@ def is_re(obj: object) -> TypeGuard[Pattern]:
142153
143154
Parameters
144155
----------
145-
obj : The object to check
156+
obj : object
157+
The object to check for being a regex pattern. Typically,
158+
this would be an object that you expect to be a compiled
159+
pattern from the `re` module.
146160
147161
Returns
148162
-------
149163
bool
150164
Whether `obj` is a regex pattern.
151165
166+
See Also
167+
--------
168+
api.types.is_float : Return True if given object is float.
169+
api.types.is_iterator : Check if the object is an iterator.
170+
api.types.is_integer : Return True if given object is integer.
171+
api.types.is_re_compilable : Check if the object can be compiled
172+
into a regex pattern instance.
173+
152174
Examples
153175
--------
154176
>>> from pandas.api.types import is_re
@@ -275,13 +297,22 @@ def is_dict_like(obj: object) -> bool:
275297
276298
Parameters
277299
----------
278-
obj : The object to check
300+
obj : object
301+
The object to check. This can be any Python object,
302+
and the function will determine whether it
303+
behaves like a dictionary.
279304
280305
Returns
281306
-------
282307
bool
283308
Whether `obj` has dict-like properties.
284309
310+
See Also
311+
--------
312+
api.types.is_list_like : Check if the object is list-like.
313+
api.types.is_file_like : Check if the object is a file-like.
314+
api.types.is_named_tuple : Check if the object is a named tuple.
315+
285316
Examples
286317
--------
287318
>>> from pandas.api.types import is_dict_like
@@ -308,13 +339,22 @@ def is_named_tuple(obj: object) -> bool:
308339
309340
Parameters
310341
----------
311-
obj : The object to check
342+
obj : object
343+
The object that will be checked to determine
344+
whether it is a named tuple.
312345
313346
Returns
314347
-------
315348
bool
316349
Whether `obj` is a named tuple.
317350
351+
See Also
352+
--------
353+
api.types.is_dict_like: Check if the object is dict-like.
354+
api.types.is_hashable: Return True if hash(obj)
355+
will succeed, False otherwise.
356+
api.types.is_categorical_dtype : Check if the dtype is categorical.
357+
318358
Examples
319359
--------
320360
>>> from collections import namedtuple
@@ -340,9 +380,24 @@ def is_hashable(obj: object) -> TypeGuard[Hashable]:
340380
Distinguish between these and other types by trying the call to hash() and
341381
seeing if they raise TypeError.
342382
383+
Parameters
384+
----------
385+
obj : object
386+
The object to check for hashability. Any Python object can be passed here.
387+
343388
Returns
344389
-------
345390
bool
391+
True if object can be hashed (i.e., does not raise TypeError when
392+
passed to hash()), and False otherwise (e.g., if object is mutable
393+
like a list or dictionary).
394+
395+
See Also
396+
--------
397+
api.types.is_float : Return True if given object is float.
398+
api.types.is_iterator : Check if the object is an iterator.
399+
api.types.is_list_like : Check if the object is list-like.
400+
api.types.is_dict_like : Check if the object is dict-like.
346401
347402
Examples
348403
--------

0 commit comments

Comments
 (0)