Skip to content

Commit 78c157b

Browse files
committed
Merge remote-tracking branch 'upstream/main' into enh-pd-cut
2 parents d0eecda + 2a9855b commit 78c157b

Some content is hidden

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

73 files changed

+783
-946
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ jobs:
391391
env:
392392
PYTHON_GIL: 0
393393

394+
# NOTE: this job must be kept in sync with the Pyodide build job in wheels.yml
394395
emscripten:
395396
# Note: the Python version, Emscripten toolchain version are determined
396397
# by the Pyodide version. The appropriate versions can be found in the

.github/workflows/wheels.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ jobs:
100100
- [windows-2022, win_amd64]
101101
# TODO: support PyPy?
102102
python: [["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"]]
103+
104+
# Build Pyodide wheels and upload them to Anaconda.org
105+
# NOTE: this job is similar to the one in unit-tests.yml except for the fact
106+
# that it uses cibuildwheel instead of a standard Pyodide xbuildenv setup.
107+
include:
108+
- buildplat: [ubuntu-22.04, pyodide_wasm32]
109+
python: ["cp312", "3.12"]
103110
env:
104111
IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
105112
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
@@ -140,12 +147,13 @@ jobs:
140147
run: echo "sdist_name=$(cd ./dist && ls -d */)" >> "$GITHUB_ENV"
141148

142149
- name: Build wheels
143-
uses: pypa/[email protected].1
150+
uses: pypa/[email protected].2
144151
with:
145152
package-dir: ./dist/${{ startsWith(matrix.buildplat[1], 'macosx') && env.sdist_name || needs.build_sdist.outputs.sdist_file }}
146153
env:
147154
CIBW_PRERELEASE_PYTHONS: True
148155
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
156+
CIBW_PLATFORM: ${{ matrix.buildplat[1] == 'pyodide_wasm32' && 'pyodide' || 'auto' }}
149157

150158
- name: Set up Python
151159
uses: mamba-org/setup-micromamba@v1

asv_bench/benchmarks/indexing.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -546,24 +546,17 @@ def time_chained_indexing(self, mode):
546546

547547

548548
class Block:
549-
params = [
550-
(True, "True"),
551-
(np.array(True), "np.array(True)"),
552-
]
553-
554-
def setup(self, true_value, mode):
549+
def setup(self):
555550
self.df = DataFrame(
556551
False,
557552
columns=np.arange(500).astype(str),
558553
index=date_range("2010-01-01", "2011-01-01"),
559554
)
560555

561-
self.true_value = true_value
562-
563-
def time_test(self, true_value, mode):
556+
def time_test(self):
564557
start = datetime(2010, 5, 1)
565558
end = datetime(2010, 9, 1)
566-
self.df.loc[start:end, :] = true_value
559+
self.df.loc[start:end, :] = True
567560

568561

569562
from .pandas_vb_common import setup # noqa: F401 isort:skip

ci/code_checks.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7070
--format=actions \
7171
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
73-
-i "pandas.DataFrame.max RT03" \
74-
-i "pandas.DataFrame.mean RT03" \
75-
-i "pandas.DataFrame.median RT03" \
76-
-i "pandas.DataFrame.min RT03" \
7773
-i "pandas.DataFrame.plot PR02" \
7874
-i "pandas.Grouper PR02" \
7975
-i "pandas.MultiIndex.append PR07,SA01" \
@@ -95,7 +91,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
9591
-i "pandas.Period.freq GL08" \
9692
-i "pandas.Period.freqstr SA01" \
9793
-i "pandas.Period.month SA01" \
98-
-i "pandas.Period.now SA01" \
9994
-i "pandas.Period.ordinal GL08" \
10095
-i "pandas.Period.strftime PR01,SA01" \
10196
-i "pandas.Period.to_timestamp SA01" \
@@ -167,7 +162,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
167162
-i "pandas.Series.product RT03" \
168163
-i "pandas.Series.reorder_levels RT03,SA01" \
169164
-i "pandas.Series.sem PR01,RT03,SA01" \
170-
-i "pandas.Series.skew RT03,SA01" \
165+
-i "pandas.Series.skew SA01" \
171166
-i "pandas.Series.sparse PR01,SA01" \
172167
-i "pandas.Series.sparse.density SA01" \
173168
-i "pandas.Series.sparse.fill_value SA01" \

doc/source/getting_started/intro_tutorials/04_plotting.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ How do I create plots in pandas?
3232
air_quality.head()
3333
3434
.. note::
35-
The usage of the ``index_col`` and ``parse_dates`` parameters of the ``read_csv`` function to define the first (0th) column as
36-
index of the resulting ``DataFrame`` and convert the dates in the column to :class:`Timestamp` objects, respectively.
35+
The ``index_col=0`` and ``parse_dates=True`` parameters passed to the ``read_csv`` function define
36+
the first (0th) column as index of the resulting ``DataFrame`` and convert the dates in the column
37+
to :class:`Timestamp` objects, respectively.
38+
3739

3840
.. raw:: html
3941

doc/source/getting_started/overview.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
Package overview
77
****************
88

9-
pandas is a `Python <https://www.python.org>`__ package providing fast,
9+
pandas is a `Python <https://www.python.org>`__ package that provides fast,
1010
flexible, and expressive data structures designed to make working with
1111
"relational" or "labeled" data both easy and intuitive. It aims to be the
12-
fundamental high-level building block for doing practical, **real-world** data
13-
analysis in Python. Additionally, it has the broader goal of becoming **the
12+
fundamental high-level building block for Python's practical, **real-world** data
13+
analysis. Additionally, it seeks to become **the
1414
most powerful and flexible open source data analysis/manipulation tool
1515
available in any language**. It is already well on its way toward this goal.
1616

doc/source/user_guide/categorical.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ Assigning a ``Categorical`` to parts of a column of other types will use the val
793793
:okwarning:
794794
795795
df = pd.DataFrame({"a": [1, 1, 1, 1, 1], "b": ["a", "a", "a", "a", "a"]})
796-
df.loc[1:2, "a"] = pd.Categorical(["b", "b"], categories=["a", "b"])
796+
df.loc[1:2, "a"] = pd.Categorical([2, 2], categories=[2, 3])
797797
df.loc[2:3, "b"] = pd.Categorical(["b", "b"], categories=["a", "b"])
798798
df
799799
df.dtypes

doc/source/whatsnew/v3.0.0.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Other enhancements
4343
- :func:`cut` now supports a string for ``bins`` kwarg by dispatching to ``numpy.histogram_bin_edges``. (:issue:`59165`)
4444
- :meth:`DataFrame.corrwith` now accepts ``min_periods`` as optional arguments, as in :meth:`DataFrame.corr` and :meth:`Series.corr` (:issue:`9490`)
4545
- :meth:`DataFrame.cummin`, :meth:`DataFrame.cummax`, :meth:`DataFrame.cumprod` and :meth:`DataFrame.cumsum` methods now have a ``numeric_only`` parameter (:issue:`53072`)
46+
- :meth:`DataFrame.ewm` now allows ``adjust=False`` when ``times`` is provided (:issue:`54328`)
4647
- :meth:`DataFrame.fillna` and :meth:`Series.fillna` can now accept ``value=None``; for non-object dtype the corresponding NA value will be used (:issue:`57723`)
4748
- :meth:`DataFrame.pivot_table` and :func:`pivot_table` now allow the passing of keyword arguments to ``aggfunc`` through ``**kwargs`` (:issue:`57884`)
4849
- :meth:`Series.cummin` and :meth:`Series.cummax` now supports :class:`CategoricalDtype` (:issue:`52335`)
@@ -361,6 +362,7 @@ Other Removals
361362
- Changed the default value of ``na_action`` in :meth:`Categorical.map` to ``None`` (:issue:`51645`)
362363
- Changed the default value of ``observed`` in :meth:`DataFrame.groupby` and :meth:`Series.groupby` to ``True`` (:issue:`51811`)
363364
- Enforce deprecation in :func:`testing.assert_series_equal` and :func:`testing.assert_frame_equal` with object dtype and mismatched null-like values, which are now considered not-equal (:issue:`18463`)
365+
- Enforce banning of upcasting in in-place setitem-like operations (:issue:`59007`) (see `PDEP6 <https://pandas.pydata.org/pdeps/0006-ban-upcasting.html>`_)
364366
- Enforced deprecation ``all`` and ``any`` reductions with ``datetime64``, :class:`DatetimeTZDtype`, and :class:`PeriodDtype` dtypes (:issue:`58029`)
365367
- Enforced deprecation disallowing ``float`` "periods" in :func:`date_range`, :func:`period_range`, :func:`timedelta_range`, :func:`interval_range`, (:issue:`56036`)
366368
- Enforced deprecation disallowing parsing datetimes with mixed time zones unless user passes ``utc=True`` to :func:`to_datetime` (:issue:`57275`)
@@ -382,6 +384,8 @@ Other Removals
382384
- Enforced deprecation of string ``A`` denoting frequency in :class:`YearEnd` and strings ``A-DEC``, ``A-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`57699`)
383385
- Enforced deprecation of string ``BAS`` denoting frequency in :class:`BYearBegin` and strings ``BAS-DEC``, ``BAS-JAN``, etc. denoting annual frequencies with various fiscal year starts (:issue:`57793`)
384386
- Enforced deprecation of string ``BA`` denoting frequency in :class:`BYearEnd` and strings ``BA-DEC``, ``BA-JAN``, etc. denoting annual frequencies with various fiscal year ends (:issue:`57793`)
387+
- Enforced deprecation of strings ``H``, ``BH``, and ``CBH`` denoting frequencies in :class:`Hour`, :class:`BusinessHour`, :class:`CustomBusinessHour` (:issue:`59143`)
388+
- Enforced deprecation of strings ``H``, ``BH``, and ``CBH`` denoting units in :class:`Timedelta` (:issue:`59143`)
385389
- Enforced deprecation of strings ``T``, ``L``, ``U``, and ``N`` denoting frequencies in :class:`Minute`, :class:`Milli`, :class:`Micro`, :class:`Nano` (:issue:`57627`)
386390
- Enforced deprecation of strings ``T``, ``L``, ``U``, and ``N`` denoting units in :class:`Timedelta` (:issue:`57627`)
387391
- Enforced deprecation of the behavior of :func:`concat` when ``len(keys) != len(objs)`` would truncate to the shorter of the two. Now this raises a ``ValueError`` (:issue:`43485`)
@@ -503,6 +507,7 @@ Datetimelike
503507
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` does not raise on Custom business days frequencies bigger then "1C" (:issue:`58664`)
504508
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` returning ``False`` on double-digit frequencies (:issue:`58523`)
505509
- Bug in :meth:`DatetimeIndex.union` when ``unit`` was non-nanosecond (:issue:`59036`)
510+
- Bug in :meth:`Series.dt.microsecond` producing incorrect results for pyarrow backed :class:`Series`. (:issue:`59154`)
506511
- Bug in setting scalar values with mismatched resolution into arrays with non-nanosecond ``datetime64``, ``timedelta64`` or :class:`DatetimeTZDtype` incorrectly truncating those scalars (:issue:`56410`)
507512

508513
Timedelta
@@ -552,11 +557,13 @@ MultiIndex
552557
- :func:`DataFrame.loc` with ``axis=0`` and :class:`MultiIndex` when setting a value adds extra columns (:issue:`58116`)
553558
- :meth:`DataFrame.melt` would not accept multiple names in ``var_name`` when the columns were a :class:`MultiIndex` (:issue:`58033`)
554559
- :meth:`MultiIndex.insert` would not insert NA value correctly at unified location of index -1 (:issue:`59003`)
560+
- :func:`MultiIndex.get_level_values` accessing a :class:`DatetimeIndex` does not carry the frequency attribute along (:issue:`58327`, :issue:`57949`)
555561
-
556562

557563
I/O
558564
^^^
559565
- Bug in :class:`DataFrame` and :class:`Series` ``repr`` of :py:class:`collections.abc.Mapping`` elements. (:issue:`57915`)
566+
- Bug in :meth:`.DataFrame.to_json` when ``"index"`` was a value in the :attr:`DataFrame.column` and :attr:`Index.name` was ``None``. Now, this will fail with a ``ValueError`` (:issue:`58925`)
560567
- Bug in :meth:`DataFrame.to_dict` raises unnecessary ``UserWarning`` when columns are not unique and ``orient='tight'``. (:issue:`58281`)
561568
- Bug in :meth:`DataFrame.to_excel` when writing empty :class:`DataFrame` with :class:`MultiIndex` on both axes (:issue:`57696`)
562569
- Bug in :meth:`DataFrame.to_stata` when writing :class:`DataFrame` and ``byteorder=`big```. (:issue:`58969`)

pandas/_libs/tslibs/dtypes.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ cdef bint is_supported_unit(NPY_DATETIMEUNIT reso)
1414
cdef dict c_OFFSET_TO_PERIOD_FREQSTR
1515
cdef dict c_PERIOD_TO_OFFSET_FREQSTR
1616
cdef dict c_OFFSET_RENAMED_FREQSTR
17-
cdef dict c_DEPR_ABBREVS
1817
cdef dict c_DEPR_UNITS
1918
cdef dict c_PERIOD_AND_OFFSET_DEPR_FREQSTR
2019
cdef dict attrname_to_abbrevs
2120
cdef dict npy_unit_to_attrname
2221
cdef dict attrname_to_npy_unit
22+
cdef str INVALID_FREQ_ERR_MSG
2323

2424
cdef enum c_FreqGroup:
2525
# Mirrors FreqGroup in the .pyx file

pandas/_libs/tslibs/dtypes.pyx

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# period frequency constants corresponding to scikits timeseries
22
# originals
33
from enum import Enum
4-
import warnings
5-
6-
from pandas.util._exceptions import find_stack_level
74

85
from pandas._libs.tslibs.ccalendar cimport c_MONTH_NUMBERS
96
from pandas._libs.tslibs.np_datetime cimport (
@@ -338,14 +335,6 @@ PERIOD_TO_OFFSET_FREQSTR = {
338335
cdef dict c_OFFSET_TO_PERIOD_FREQSTR = OFFSET_TO_PERIOD_FREQSTR
339336
cdef dict c_PERIOD_TO_OFFSET_FREQSTR = PERIOD_TO_OFFSET_FREQSTR
340337

341-
# Map deprecated resolution abbreviations to correct resolution abbreviations
342-
cdef dict c_DEPR_ABBREVS = {
343-
"H": "h",
344-
"BH": "bh",
345-
"CBH": "cbh",
346-
"S": "s",
347-
}
348-
349338
cdef dict c_DEPR_UNITS = {
350339
"w": "W",
351340
"d": "D",
@@ -372,6 +361,8 @@ cdef dict c_PERIOD_AND_OFFSET_DEPR_FREQSTR = {
372361
"MIN": "min",
373362
}
374363

364+
cdef str INVALID_FREQ_ERR_MSG = "Invalid frequency: {0}"
365+
375366

376367
class FreqGroup(Enum):
377368
# Mirrors c_FreqGroup in the .pxd file
@@ -461,39 +452,18 @@ class Resolution(Enum):
461452
>>> Resolution.get_reso_from_freqstr('h') == Resolution.RESO_HR
462453
True
463454
"""
464-
cdef:
465-
str abbrev
466455
try:
467-
if freq in c_DEPR_ABBREVS:
468-
abbrev = c_DEPR_ABBREVS[freq]
469-
warnings.warn(
470-
f"\'{freq}\' is deprecated and will be removed in a future "
471-
f"version. Please use \'{abbrev}\' "
472-
f"instead of \'{freq}\'.",
473-
FutureWarning,
474-
stacklevel=find_stack_level(),
475-
)
476-
freq = abbrev
477456
attr_name = _abbrev_to_attrnames[freq]
478-
except KeyError:
457+
except KeyError as exc:
458+
msg = INVALID_FREQ_ERR_MSG.format(freq)
479459
# For quarterly and yearly resolutions, we need to chop off
480460
# a month string.
481461
split_freq = freq.split("-")
482462
if len(split_freq) != 2:
483-
raise
463+
raise ValueError(msg) from exc
484464
if split_freq[1] not in _month_names:
485465
# i.e. we want e.g. "Q-DEC", not "Q-INVALID"
486-
raise
487-
if split_freq[0] in c_DEPR_ABBREVS:
488-
abbrev = c_DEPR_ABBREVS[split_freq[0]]
489-
warnings.warn(
490-
f"\'{split_freq[0]}\' is deprecated and will be removed in a "
491-
f"future version. Please use \'{abbrev}\' "
492-
f"instead of \'{split_freq[0]}\'.",
493-
FutureWarning,
494-
stacklevel=find_stack_level(),
495-
)
496-
split_freq[0] = abbrev
466+
raise ValueError(msg) from exc
497467
attr_name = _abbrev_to_attrnames[split_freq[0]]
498468

499469
return cls.from_attrname(attr_name)

0 commit comments

Comments
 (0)