Skip to content

Commit 75203ae

Browse files
committed
Merge remote-tracking branch 'upstream/main' into dateoffset-bug
2 parents dcb4244 + 841ebb1 commit 75203ae

File tree

135 files changed

+1908
-797
lines changed

Some content is hidden

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

135 files changed

+1908
-797
lines changed

.github/workflows/unit-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ jobs:
230230
/opt/python/cp39-cp39/bin/python -m venv ~/virtualenvs/pandas-dev
231231
. ~/virtualenvs/pandas-dev/bin/activate
232232
python -m pip install -U pip wheel setuptools meson[ninja]==1.0.1 meson-python==0.13.1
233-
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
233+
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
234234
python -m pip install --no-cache-dir --no-build-isolation -e .
235235
python -m pip list --no-cache-dir
236236
export PANDAS_CI=1
@@ -268,7 +268,7 @@ jobs:
268268
/opt/python/cp39-cp39/bin/python -m venv ~/virtualenvs/pandas-dev
269269
. ~/virtualenvs/pandas-dev/bin/activate
270270
python -m pip install -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.0.1
271-
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
271+
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
272272
python -m pip install --no-cache-dir --no-build-isolation -e .
273273
python -m pip list --no-cache-dir
274274
@@ -340,7 +340,7 @@ jobs:
340340
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
341341
python -m pip install git+https://github.com/nedbat/coveragepy.git
342342
python -m pip install versioneer[toml]
343-
python -m pip install python-dateutil pytz cython hypothesis>=6.46.1 pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-cov pytest-asyncio>=0.17
343+
python -m pip install python-dateutil pytz cython hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov pytest-asyncio>=0.17
344344
python -m pip list
345345
346346
- name: Build Pandas

.github/workflows/wheels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140
shell: pwsh
141141
run: |
142142
$TST_CMD = @"
143-
python -m pip install pytz six numpy python-dateutil tzdata>=2022.1 hypothesis>=6.46.1 pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17;
143+
python -m pip install pytz six numpy python-dateutil tzdata>=2022.1 hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17;
144144
python -m pip install --find-links=pandas\wheelhouse --no-index pandas;
145145
python -c `'import pandas as pd; pd.test()`';
146146
"@

asv_bench/benchmarks/multiindex_object.py

+26
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,30 @@ def time_putmask_all_different(self):
396396
self.midx.putmask(self.mask, self.midx_values_different)
397397

398398

399+
class Append:
400+
params = ["datetime64[ns]", "int64", "string"]
401+
param_names = ["dtype"]
402+
403+
def setup(self, dtype):
404+
N1 = 1000
405+
N2 = 500
406+
left_level1 = range(N1)
407+
right_level1 = range(N1, N1 + N1)
408+
409+
if dtype == "datetime64[ns]":
410+
level2 = date_range(start="2000-01-01", periods=N2)
411+
elif dtype == "int64":
412+
level2 = range(N2)
413+
elif dtype == "string":
414+
level2 = tm.makeStringIndex(N2)
415+
else:
416+
raise NotImplementedError
417+
418+
self.left = MultiIndex.from_product([left_level1, level2])
419+
self.right = MultiIndex.from_product([right_level1, level2])
420+
421+
def time_append(self, dtype):
422+
self.left.append(self.right)
423+
424+
399425
from .pandas_vb_common import setup # noqa: F401 isort:skip

ci/code_checks.sh

-14
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
105105
pandas.errors.UnsupportedFunctionCall \
106106
pandas.test \
107107
pandas.NaT \
108-
pandas.Timestamp.date \
109-
pandas.Timestamp.dst \
110-
pandas.Timestamp.isocalendar \
111-
pandas.Timestamp.isoweekday \
112-
pandas.Timestamp.strptime \
113-
pandas.Timestamp.time \
114-
pandas.Timestamp.timetuple \
115-
pandas.Timestamp.timetz \
116-
pandas.Timestamp.to_datetime64 \
117-
pandas.Timestamp.toordinal \
118-
pandas.Timestamp.tzname \
119-
pandas.Timestamp.utcoffset \
120-
pandas.Timestamp.utctimetuple \
121-
pandas.Timestamp.weekday \
122108
pandas.arrays.TimedeltaArray \
123109
pandas.Period.asfreq \
124110
pandas.Period.now \

ci/deps/actions-310.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- meson-python=0.13.1
1212

1313
# test dependencies
14-
- pytest>=7.0.0
14+
- pytest>=7.3.2
1515
- pytest-cov
1616
- pytest-xdist>=2.2.0
1717
- pytest-asyncio>=0.17.0

ci/deps/actions-311-downstream_compat.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- meson-python=0.13.1
1313

1414
# test dependencies
15-
- pytest>=7.0.0
15+
- pytest>=7.3.2
1616
- pytest-cov
1717
- pytest-xdist>=2.2.0
1818
- pytest-asyncio>=0.17.0

ci/deps/actions-311-numpydev.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- meson-python=0.13.1
1111

1212
# test dependencies
13-
- pytest>=7.0.0
13+
- pytest>=7.3.2
1414
- pytest-cov
1515
# Once pytest-cov > 4 comes out, unpin this
1616
# Right now, a DeprecationWarning related to rsyncdir

ci/deps/actions-311-pyarrownightly.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- meson-python=0.13.1
1212

1313
# test dependencies
14-
- pytest>=7.0.0
14+
- pytest>=7.3.2
1515
- pytest-cov
1616
- pytest-xdist>=2.2.0
1717
- hypothesis>=6.46.1

ci/deps/actions-311.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- meson-python=0.13.1
1212

1313
# test dependencies
14-
- pytest>=7.0.0
14+
- pytest>=7.3.2
1515
- pytest-cov
1616
- pytest-xdist>=2.2.0
1717
- pytest-asyncio>=0.17.0

ci/deps/actions-39-minimum_versions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- meson-python=0.13.1
1414

1515
# test dependencies
16-
- pytest>=7.0.0
16+
- pytest>=7.3.2
1717
- pytest-cov
1818
- pytest-xdist>=2.2.0
1919
- pytest-asyncio>=0.17.0

ci/deps/actions-39.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- meson-python=0.13.1
1212

1313
# test dependencies
14-
- pytest>=7.0.0
14+
- pytest>=7.3.2
1515
- pytest-cov
1616
- pytest-xdist>=2.2.0
1717
- pytest-asyncio>=0.17.0

ci/deps/actions-pypy-39.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- meson-python=0.13.1
1515

1616
# test dependencies
17-
- pytest>=7.0.0
17+
- pytest>=7.3.2
1818
- pytest-cov
1919
- pytest-asyncio>=0.17.0
2020
- pytest-xdist>=2.2.0

ci/deps/circle-310-arm64.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- meson-python=0.13.1
1212

1313
# test dependencies
14-
- pytest>=7.0.0
14+
- pytest>=7.3.2
1515
- pytest-cov
1616
- pytest-xdist>=2.2.0
1717
- pytest-asyncio>=0.17.0

ci/meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test:
6262
- python -c "import pandas; pandas.test(extra_args={{ extra_args }})" # [python_impl == "cpython"]
6363
requires:
6464
- pip
65-
- pytest >=7.0.0
65+
- pytest >=7.3.2
6666
- pytest-asyncio >=0.17.0
6767
- pytest-xdist >=2.2.0
6868
- pytest-cov

doc/source/user_guide/io.rst

+10-6
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,8 @@ Reading from a JSON string:
21112111

21122112
.. ipython:: python
21132113
2114-
pd.read_json(json)
2114+
from io import StringIO
2115+
pd.read_json(StringIO(json))
21152116
21162117
Reading from a file:
21172118

@@ -2135,6 +2136,7 @@ Preserve string indices:
21352136

21362137
.. ipython:: python
21372138
2139+
from io import StringIO
21382140
si = pd.DataFrame(
21392141
np.zeros((4, 4)), columns=list(range(4)), index=[str(i) for i in range(4)]
21402142
)
@@ -2143,7 +2145,7 @@ Preserve string indices:
21432145
si.columns
21442146
json = si.to_json()
21452147
2146-
sij = pd.read_json(json, convert_axes=False)
2148+
sij = pd.read_json(StringIO(json), convert_axes=False)
21472149
sij
21482150
sij.index
21492151
sij.columns
@@ -2152,18 +2154,19 @@ Dates written in nanoseconds need to be read back in nanoseconds:
21522154

21532155
.. ipython:: python
21542156
2157+
from io import StringIO
21552158
json = dfj2.to_json(date_unit="ns")
21562159
21572160
# Try to parse timestamps as milliseconds -> Won't Work
2158-
dfju = pd.read_json(json, date_unit="ms")
2161+
dfju = pd.read_json(StringIO(json), date_unit="ms")
21592162
dfju
21602163
21612164
# Let pandas detect the correct precision
2162-
dfju = pd.read_json(json)
2165+
dfju = pd.read_json(StringIO(json))
21632166
dfju
21642167
21652168
# Or specify that all timestamps are in nanoseconds
2166-
dfju = pd.read_json(json, date_unit="ns")
2169+
dfju = pd.read_json(StringIO(json), date_unit="ns")
21672170
dfju
21682171
21692172
By setting the ``dtype_backend`` argument you can control the default dtypes used for the resulting DataFrame.
@@ -2251,11 +2254,12 @@ For line-delimited json files, pandas can also return an iterator which reads in
22512254

22522255
.. ipython:: python
22532256
2257+
from io import StringIO
22542258
jsonl = """
22552259
{"a": 1, "b": 2}
22562260
{"a": 3, "b": 4}
22572261
"""
2258-
df = pd.read_json(jsonl, lines=True)
2262+
df = pd.read_json(StringIO(jsonl), lines=True)
22592263
df
22602264
df.to_json(orient="records", lines=True)
22612265

doc/source/user_guide/timedeltas.rst

-3
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,6 @@ an alternative is to divide by another timedelta object. Note that division by t
259259
# to days
260260
td / np.timedelta64(1, "D")
261261
262-
# to months (these are constant months)
263-
td / np.timedelta64(1, "M")
264-
265262
Dividing or multiplying a ``timedelta64[ns]`` Series by an integer or integer Series
266263
yields another ``timedelta64[ns]`` dtypes Series.
267264

doc/source/user_guide/window.rst

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ For example, a `weighted mean <https://en.wikipedia.org/wiki/Weighted_arithmetic
8989
be calculated with :meth:`~Rolling.apply` by specifying a separate column of weights.
9090

9191
.. ipython:: python
92+
:okwarning:
9293
9394
def weighted_mean(x):
9495
arr = np.ones((1, x.shape[1]))
@@ -114,6 +115,7 @@ the ``update`` argument to continue the windowing calculation.
114115
df.ewm(0.5).mean()
115116
116117
.. ipython:: python
118+
:okwarning:
117119
118120
online_ewm = df.head(2).ewm(0.5).online()
119121
online_ewm.mean()

doc/source/whatsnew/v1.5.0.rst

+8-5
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,22 @@ upon serialization. (Related issue :issue:`12997`)
474474
475475
.. code-block:: ipython
476476
477-
In [4]: a.to_json(date_format='iso')
478-
Out[4]: '{"2020-12-28T00:00:00.000Z":0,"2020-12-28T01:00:00.000Z":1,"2020-12-28T02:00:00.000Z":2}'
477+
In [4]: from io import StringIO
479478
480-
In [5]: pd.read_json(a.to_json(date_format='iso'), typ="series").index == a.index
481-
Out[5]: array([False, False, False])
479+
In [5]: a.to_json(date_format='iso')
480+
Out[5]: '{"2020-12-28T00:00:00.000Z":0,"2020-12-28T01:00:00.000Z":1,"2020-12-28T02:00:00.000Z":2}'
481+
482+
In [6]: pd.read_json(StringIO(a.to_json(date_format='iso')), typ="series").index == a.index
483+
Out[6]: array([False, False, False])
482484
483485
*New Behavior*
484486

485487
.. ipython:: python
486488
489+
from io import StringIO
487490
a.to_json(date_format='iso')
488491
# Roundtripping now works
489-
pd.read_json(a.to_json(date_format='iso'), typ="series").index == a.index
492+
pd.read_json(StringIO(a.to_json(date_format='iso')), typ="series").index == a.index
490493
491494
.. _whatsnew_150.notable_bug_fixes.groupby_value_counts_categorical:
492495

doc/source/whatsnew/v2.0.3.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ including other versions of pandas.
1414
Fixed regressions
1515
~~~~~~~~~~~~~~~~~
1616
- Fixed performance regression in merging on datetime-like columns (:issue:`53231`)
17+
- For external ExtensionArray implementations, restored the default use of ``_values_for_factorize`` for hashing arrays (:issue:`53475`)
1718
-
1819

1920
.. ---------------------------------------------------------------------------
2021
.. _whatsnew_203.bug_fixes:
2122

2223
Bug fixes
2324
~~~~~~~~~
24-
- Bug in :class:`DateOffset` which had inconsistent behavior when multiplying a :class:`DateOffset` object by a constant (:issue:`47953`)
2525
- Bug in :func:`RangeIndex.union` when using ``sort=True`` with another :class:`RangeIndex` (:issue:`53490`)
26+
- Bug in :func:`Series.reindex` when expanding a non-nanosecond datetime or timedelta :class:`Series` would not fill with ``NaT`` correctly (:issue:`53497`)
2627
- Bug in :func:`read_csv` when defining ``dtype`` with ``bool[pyarrow]`` for the ``"c"`` and ``"python"`` engines (:issue:`53390`)
2728
- Bug in :meth:`Series.str.split` and :meth:`Series.str.rsplit` with ``expand=True`` for :class:`ArrowDtype` with ``pyarrow.string`` (:issue:`53532`)
2829
- Bug in indexing methods (e.g. :meth:`DataFrame.__getitem__`) where taking the entire :class:`DataFrame`/:class:`Series` would raise an ``OverflowError`` when Copy on Write was enabled and the length of the array was over the maximum size a 32-bit integer can hold (:issue:`53616`)
29-
-
30+
- Bug when constructing a :class:`DataFrame` with columns of an :class:`ArrowDtype` with a ``pyarrow.dictionary`` type that reindexes the data (:issue:`53617`)
31+
- Bug when indexing a :class:`DataFrame` or :class:`Series` with an :class:`Index` with a timestamp :class:`ArrowDtype` would raise an ``AttributeError`` (:issue:`53644`)
3032

3133
.. ---------------------------------------------------------------------------
3234
.. _whatsnew_203.other:

0 commit comments

Comments
 (0)