Skip to content

Commit 3c08806

Browse files
committed
Merge remote-tracking branch 'upstream/main' into cln/assorted
2 parents ad16876 + 185c53f commit 3c08806

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+292
-251
lines changed

ci/code_checks.sh

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,8 @@ fi
7979
### DOCSTRINGS ###
8080
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8181

82-
MSG='Validate docstrings (EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
83-
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
84-
RET=$(($RET + $?)) ; echo $MSG "DONE"
85-
86-
MSG='Partially validate docstrings (RT02)' ; echo $MSG
87-
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=RT02 --ignore_functions \
88-
pandas.Index.all \
89-
pandas.Index.any \
90-
pandas.MultiIndex.drop \
91-
pandas.DatetimeIndex.to_pydatetime \
92-
pandas.TimedeltaIndex.to_pytimedelta \
93-
pandas.io.formats.style.Styler.export \
94-
pandas.api.extensions.ExtensionArray.astype \
95-
pandas.api.extensions.ExtensionArray.dropna \
96-
pandas.api.extensions.ExtensionArray.isna \
97-
pandas.api.extensions.ExtensionArray.repeat \
98-
pandas.api.extensions.ExtensionArray.unique
82+
MSG='Validate docstrings (EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
83+
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
9984
RET=$(($RET + $?)) ; echo $MSG "DONE"
10085

10186
fi

doc/source/development/contributing_gitpod.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ docs you need to run the following command in the docs directory::
145145

146146
Alternatively you can build a single page with::
147147

148-
python make.py html python make.py --single development/contributing_gitpod.rst
148+
python make.py --single development/contributing_gitpod.rst
149149

150150
You have two main options to render the documentation in Gitpod.
151151

doc/source/user_guide/timeseries.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ The default behavior, ``errors='raise'``, is to raise when unparsable:
292292
.. code-block:: ipython
293293
294294
In [2]: pd.to_datetime(['2009/07/31', 'asd'], errors='raise')
295-
ValueError: Unknown string format
295+
ValueError: Unknown datetime string format
296296
297297
Pass ``errors='ignore'`` to return the original input when unparsable:
298298

doc/source/whatsnew/v2.0.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ Other enhancements
165165
- Improved error message in :func:`to_datetime` for non-ISO8601 formats, informing users about the position of the first error (:issue:`50361`)
166166
- Improved error message when trying to align :class:`DataFrame` objects (for example, in :func:`DataFrame.compare`) to clarify that "identically labelled" refers to both index and columns (:issue:`50083`)
167167
- Added :meth:`DatetimeIndex.as_unit` and :meth:`TimedeltaIndex.as_unit` to convert to different resolutions; supported resolutions are "s", "ms", "us", and "ns" (:issue:`50616`)
168+
- Added new argument ``dtype`` to :func:`read_sql` to be consistent with :func:`read_sql_query` (:issue:`50797`)
168169
-
169170

170171
.. ---------------------------------------------------------------------------
@@ -950,6 +951,7 @@ Datetimelike
950951
- Bug in :func:`to_datetime` was failing to parse date strings ``'today'`` and ``'now'`` if ``format`` was not ISO8601 (:issue:`50359`)
951952
- Bug in :func:`Timestamp.utctimetuple` raising a ``TypeError`` (:issue:`32174`)
952953
- Bug in :func:`to_datetime` was raising ``ValueError`` when parsing mixed-offset :class:`Timestamp` with ``errors='ignore'`` (:issue:`50585`)
954+
- Bug in :func:`to_datetime` was incorrectly handling floating-point inputs within 1 ``unit`` of the overflow boundaries (:issue:`50183`)
953955

954956
Timedelta
955957
^^^^^^^^^

pandas/_libs/lib.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,6 @@ def get_reverse_indexer(
240240
) -> npt.NDArray[np.intp]: ...
241241
def is_bool_list(obj: list) -> bool: ...
242242
def dtypes_all_equal(types: list[DtypeObj]) -> bool: ...
243-
def array_equal_fast(
244-
left: np.ndarray, right: np.ndarray # np.ndarray[np.int64, ndim=1]
243+
def is_range_indexer(
244+
left: np.ndarray, n: int # np.ndarray[np.int64, ndim=1]
245245
) -> bool: ...

pandas/_libs/lib.pyx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,22 +650,20 @@ ctypedef fused int6432_t:
650650

651651
@cython.wraparound(False)
652652
@cython.boundscheck(False)
653-
def array_equal_fast(
654-
ndarray[int6432_t, ndim=1] left, ndarray[int6432_t, ndim=1] right,
655-
) -> bool:
653+
def is_range_indexer(ndarray[int6432_t, ndim=1] left, int n) -> bool:
656654
"""
657655
Perform an element by element comparison on 1-d integer arrays, meant for indexer
658656
comparisons
659657
"""
660658
cdef:
661-
Py_ssize_t i, n = left.size
659+
Py_ssize_t i
662660

663-
if left.size != right.size:
661+
if left.size != n:
664662
return False
665663

666664
for i in range(n):
667665

668-
if left[i] != right[i]:
666+
if left[i] != i:
669667
return False
670668

671669
return True

pandas/_libs/tslib.pyx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def array_with_unit_to_datetime(
273273
bint is_coerce = errors=="coerce"
274274
bint is_raise = errors=="raise"
275275
ndarray[int64_t] iresult
276-
object tz = None
276+
tzinfo tz = None
277277
float fval
278278

279279
assert is_ignore or is_coerce or is_raise
@@ -346,7 +346,7 @@ cdef _array_with_unit_to_datetime_object_fallback(ndarray[object] values, str un
346346
cdef:
347347
Py_ssize_t i, n = len(values)
348348
ndarray[object] oresult
349-
object tz = None
349+
tzinfo tz = None
350350

351351
# TODO: fix subtle differences between this and no-unit code
352352
oresult = cnp.PyArray_EMPTY(values.ndim, values.shape, cnp.NPY_OBJECT, 0)
@@ -497,15 +497,9 @@ cpdef array_to_datetime(
497497

498498
if val != val or val == NPY_NAT:
499499
iresult[i] = NPY_NAT
500-
elif is_raise or is_ignore:
501-
iresult[i] = val
502500
else:
503-
# coerce
504501
# we now need to parse this as if unit='ns'
505-
try:
506-
iresult[i] = cast_from_unit(val, "ns")
507-
except OverflowError:
508-
iresult[i] = NPY_NAT
502+
iresult[i] = cast_from_unit(val, "ns")
509503

510504
elif isinstance(val, str):
511505
# string

pandas/_libs/tslibs/conversion.pyx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,16 +544,9 @@ cdef _TSObject convert_str_to_tsobject(str ts, tzinfo tz, str unit,
544544
maybe_localize_tso(obj, tz, obj.creso)
545545
return obj
546546

547-
try:
548-
dt = parse_datetime_string(
549-
ts, dayfirst=dayfirst, yearfirst=yearfirst
550-
)
551-
except ValueError as err:
552-
if "out of range for month" in str(err):
553-
# dateutil raised when constructing a datetime object,
554-
# let's give a nicer exception message
555-
raise ValueError("could not convert string to Timestamp") from err
556-
raise
547+
dt = parse_datetime_string(
548+
ts, dayfirst=dayfirst, yearfirst=yearfirst
549+
)
557550

558551
return convert_datetime_to_tsobject(dt, tz)
559552

pandas/_libs/tslibs/dtypes.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cpdef int64_t periods_per_second(NPY_DATETIMEUNIT reso) except? -1
1111
cpdef NPY_DATETIMEUNIT get_supported_reso(NPY_DATETIMEUNIT reso)
1212

1313
cdef dict attrname_to_abbrevs
14+
cdef dict npy_unit_to_attrname
1415

1516
cdef enum c_FreqGroup:
1617
# Mirrors FreqGroup in the .pyx file

pandas/_libs/tslibs/dtypes.pyx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,15 @@ cdef dict _reso_str_map = {
423423
}
424424

425425
cdef dict _str_reso_map = {v: k for k, v in _reso_str_map.items()}
426+
427+
cdef dict npy_unit_to_attrname = {
428+
NPY_DATETIMEUNIT.NPY_FR_Y: "year",
429+
NPY_DATETIMEUNIT.NPY_FR_M: "month",
430+
NPY_DATETIMEUNIT.NPY_FR_D: "day",
431+
NPY_DATETIMEUNIT.NPY_FR_h: "hour",
432+
NPY_DATETIMEUNIT.NPY_FR_m: "minute",
433+
NPY_DATETIMEUNIT.NPY_FR_s: "second",
434+
NPY_DATETIMEUNIT.NPY_FR_ms: "millisecond",
435+
NPY_DATETIMEUNIT.NPY_FR_us: "microsecond",
436+
NPY_DATETIMEUNIT.NPY_FR_ns: "nanosecond",
437+
}

pandas/_libs/tslibs/offsets.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2792,7 +2792,7 @@ cdef class Week(SingleConstructorOffset):
27922792
2nd week of each month.
27932793
27942794
Examples
2795-
---------
2795+
--------
27962796
27972797
>>> date_object = pd.Timestamp("2023-01-13")
27982798
>>> date_object

0 commit comments

Comments
 (0)