Skip to content

Commit c940600

Browse files
author
MarcoGorelli
committed
Merge remote-tracking branch 'upstream/main' into coercion
2 parents 919a433 + 738564e commit c940600

17 files changed

+43
-13
lines changed

asv_bench/asv.conf.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
// pip (with all the conda available packages installed first,
4242
// followed by the pip installed packages).
4343
"matrix": {
44-
"numpy": [],
44+
"numpy": ["1.23.5"], // https://github.com/pandas-dev/pandas/pull/50356
4545
"Cython": ["0.29.32"],
4646
"matplotlib": [],
4747
"sqlalchemy": [],

ci/deps/actions-310-numpydev.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ dependencies:
2222
- "cython"
2323
- "--extra-index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple"
2424
- "--pre"
25-
- "numpy"
25+
- "numpy<1.24"
2626
- "scipy"

ci/deps/actions-310.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818

1919
# required dependencies
2020
- python-dateutil
21-
- numpy
21+
- numpy<1.24
2222
- pytz
2323

2424
# optional dependencies

ci/deps/actions-38-downstream_compat.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919

2020
# required dependencies
2121
- python-dateutil
22-
- numpy
22+
- numpy<1.24
2323
- pytz
2424

2525
# optional dependencies

ci/deps/actions-38.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818

1919
# required dependencies
2020
- python-dateutil
21-
- numpy
21+
- numpy<1.24
2222
- pytz
2323

2424
# optional dependencies

ci/deps/actions-39.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818

1919
# required dependencies
2020
- python-dateutil
21-
- numpy
21+
- numpy<1.24
2222
- pytz
2323

2424
# optional dependencies

ci/deps/actions-pypy-38.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ dependencies:
1919
- hypothesis>=5.5.3
2020

2121
# required
22-
- numpy
22+
- numpy<1.24
2323
- python-dateutil
2424
- pytz

ci/deps/circle-38-arm64.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818

1919
# required dependencies
2020
- python-dateutil
21-
- numpy
21+
- numpy<1.24
2222
- pytz
2323

2424
# optional dependencies

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ I/O
896896
Period
897897
^^^^^^
898898
- Bug in :meth:`Period.strftime` and :meth:`PeriodIndex.strftime`, raising ``UnicodeDecodeError`` when a locale-specific directive was passed (:issue:`46319`)
899+
- Bug in adding a :class:`Period` object to an array of :class:`DateOffset` objects incorrectly raising ``TypeError`` (:issue:`50162`)
899900
-
900901

901902
Plotting

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020

2121
# required dependencies
2222
- python-dateutil
23-
- numpy
23+
- numpy<1.24
2424
- pytz
2525

2626
# optional dependencies

pandas/_libs/tslibs/period.pyx

+16
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,11 @@ cdef class _Period(PeriodMixin):
17411741
raise TypeError(f"unsupported operand type(s) for +: '{sname}' "
17421742
f"and '{oname}'")
17431743

1744+
elif util.is_array(other):
1745+
if other.dtype == object:
1746+
# GH#50162
1747+
return np.array([self + x for x in other], dtype=object)
1748+
17441749
return NotImplemented
17451750

17461751
def __radd__(self, other):
@@ -1767,11 +1772,22 @@ cdef class _Period(PeriodMixin):
17671772
elif other is NaT:
17681773
return NaT
17691774

1775+
elif util.is_array(other):
1776+
if other.dtype == object:
1777+
# GH#50162
1778+
return np.array([self - x for x in other], dtype=object)
1779+
17701780
return NotImplemented
17711781

17721782
def __rsub__(self, other):
17731783
if other is NaT:
17741784
return NaT
1785+
1786+
elif util.is_array(other):
1787+
if other.dtype == object:
1788+
# GH#50162
1789+
return np.array([x - self for x in other], dtype=object)
1790+
17751791
return NotImplemented
17761792

17771793
def asfreq(self, freq, how="E") -> "Period":

pandas/core/arrays/string_.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class StringArray(BaseStringArray, PandasArray):
266266
267267
See Also
268268
--------
269-
array
269+
:func:`pandas.array`
270270
The recommended function for creating a StringArray.
271271
Series.str
272272
The string methods are available on Series backed by

pandas/core/arrays/string_arrow.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ArrowStringArray(ArrowExtensionArray, BaseStringArray, ObjectStringArrayMi
8484
8585
See Also
8686
--------
87-
array
87+
:func:`pandas.array`
8888
The recommended function for creating a ArrowStringArray.
8989
Series.str
9090
The string methods are available on Series backed by

pandas/core/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -6580,6 +6580,7 @@ def fillna(
65806580
def fillna(
65816581
self: NDFrameT,
65826582
value: Hashable | Mapping | Series | DataFrame = None,
6583+
*,
65836584
method: FillnaOptions | None = None,
65846585
axis: Axis | None = None,
65856586
inplace: bool_t = False,

pandas/io/json/_table_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Table Schema builders
33
4-
https://specs.frictionlessdata.io/json-table-schema/
4+
https://specs.frictionlessdata.io/table-schema/
55
"""
66
from __future__ import annotations
77

pandas/tests/arithmetic/test_object.py

+12
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ def test_more_na_comparisons(self, dtype):
7373

7474

7575
class TestArithmetic:
76+
def test_add_period_to_array_of_offset(self):
77+
# GH#50162
78+
per = pd.Period("2012-1-1", freq="D")
79+
pi = pd.period_range("2012-1-1", periods=10, freq="D")
80+
idx = per - pi
81+
82+
expected = pd.Index([x + per for x in idx], dtype=object)
83+
result = idx + per
84+
tm.assert_index_equal(result, expected)
85+
86+
result = per + idx
87+
tm.assert_index_equal(result, expected)
7688

7789
# TODO: parametrize
7890
def test_pow_ops_object(self):

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ psutil
1111
pytest-asyncio>=0.17
1212
coverage
1313
python-dateutil
14-
numpy
14+
numpy<1.24
1515
pytz
1616
beautifulsoup4
1717
blosc

0 commit comments

Comments
 (0)