Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into sty/ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Jan 31, 2024
2 parents b40d961 + cad0d87 commit 65ac7cc
Show file tree
Hide file tree
Showing 47 changed files with 310 additions and 1,109 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/comment-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ jobs:
concurrency:
group: ${{ github.actor }}-preview-docs
steps:
- run: |
if curl --output /dev/null --silent --head --fail "https://pandas.pydata.org/preview/${{ github.event.issue.number }}/"; then
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "Website preview of this PR available at: https://pandas.pydata.org/preview/${{ github.event.issue.number }}/"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments
else
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body": "No preview found for PR #${{ github.event.issue.number }}. Did the docs build complete?"}' https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments
fi
- uses: pandas-dev/github-doc-previewer@master
with:
previewer-server: "https://pandas.pydata.org/preview"
artifact-job: "Doc Build and Upload"
asv_run:
runs-on: ubuntu-22.04
# TODO: Support more benchmarking options later, against different branches, against self, etc
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/docbuild-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,3 @@ jobs:
name: website
path: web/build
retention-days: 14

- name: Trigger web/doc preview
run: curl -X POST https://pandas.pydata.org/preview/submit/$RUN_ID/$PR_ID/
env:
RUN_ID: ${{ github.run_id }}
PR_ID: ${{ github.event.pull_request.number }}
if: github.event_name == 'pull_request'
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ repos:
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: rst-backticks
- id: rst-directive-colons
types: [text] # overwrite types: [rst]
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// pip (with all the conda available packages installed first,
// followed by the pip installed packages).
"matrix": {
"Cython": ["3.0.5"],
"Cython": ["3.0"],
"matplotlib": [],
"sqlalchemy": [],
"scipy": [],
Expand Down
6 changes: 2 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.TimedeltaIndex.ceil\
pandas.PeriodIndex\
pandas.PeriodIndex.strftime\
pandas.Series.clip\
pandas.Series.rename_axis\
pandas.Series.dt.to_period\
pandas.Series.dt.tz_localize\
Expand All @@ -115,7 +114,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.Series.plot.barh\
pandas.Series.plot.line\
pandas.Series.plot.pie\
pandas.DataFrame.clip\
pandas.DataFrame.plot\
pandas.DataFrame.plot.bar\
pandas.DataFrame.plot.barh\
Expand Down Expand Up @@ -181,10 +179,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.core.groupby.SeriesGroupBy.rolling\
pandas.core.groupby.DataFrameGroupBy.hist\
pandas.core.groupby.DataFrameGroupBy.plot\
pandas.core.groupby.DataFrameGroupBy.corrwith\
pandas.core.groupby.SeriesGroupBy.plot\
pandas.core.window.rolling.Rolling.quantile\
pandas.core.window.expanding.Expanding.quantile\
pandas.api.extensions.ExtensionArray.argsort # There should be no backslash in the final line, please keep this comment in the last ignored function
pandas.core.window.expanding.Expanding.quantile # There should be no backslash in the final line, please keep this comment in the last ignored function
RET=$(($RET + $?)) ; echo $MSG "DONE"

fi
Expand Down
15 changes: 15 additions & 0 deletions doc/source/reference/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,21 @@ To create a Series of dtype ``category``, use ``cat = s.astype(dtype)`` or
If the :class:`Series` is of dtype :class:`CategoricalDtype`, ``Series.cat`` can be used to change the categorical
data. See :ref:`api.series.cat` for more.

More methods are available on :class:`Categorical`:

.. autosummary::
:toctree: api/

Categorical.as_ordered
Categorical.as_unordered
Categorical.set_categories
Categorical.rename_categories
Categorical.reorder_categories
Categorical.add_categories
Categorical.remove_categories
Categorical.remove_unused_categories
Categorical.map

.. _api.arrays.sparse:

Sparse
Expand Down
2 changes: 0 additions & 2 deletions doc/source/reference/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ Function application
DataFrameGroupBy.describe
DataFrameGroupBy.diff
DataFrameGroupBy.ffill
DataFrameGroupBy.fillna
DataFrameGroupBy.first
DataFrameGroupBy.head
DataFrameGroupBy.idxmax
Expand Down Expand Up @@ -131,7 +130,6 @@ Function application
SeriesGroupBy.describe
SeriesGroupBy.diff
SeriesGroupBy.ffill
SeriesGroupBy.fillna
SeriesGroupBy.first
SeriesGroupBy.head
SeriesGroupBy.last
Expand Down
7 changes: 4 additions & 3 deletions doc/source/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ The following subpackages are public.
`pandas-stubs <https://github.com/pandas-dev/pandas-stubs>`_ package
which has classes in addition to those that occur in pandas for type-hinting.

In addition, public functions in ``pandas.io`` and ``pandas.tseries`` submodules
are mentioned in the documentation.
In addition, public functions in ``pandas.io``, ``pandas.tseries``, ``pandas.util`` submodules
are explicitly mentioned in the documentation. Further APIs in these modules are not guaranteed
to be stable.


.. warning::

The ``pandas.core``, ``pandas.compat``, and ``pandas.util`` top-level modules are PRIVATE. Stable functionality in such modules is not guaranteed.
The ``pandas.core``, ``pandas.compat`` top-level modules are PRIVATE. Stable functionality in such modules is not guaranteed.

.. If you update this toctree, also update the manual toctree in the
.. main index.rst.template
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ the number of groups, which is the same as the length of the ``groups`` dictiona
In [1]: gb.<TAB> # noqa: E225, E999
gb.agg gb.boxplot gb.cummin gb.describe gb.filter gb.get_group gb.height gb.last gb.median gb.ngroups gb.plot gb.rank gb.std gb.transform
gb.aggregate gb.count gb.cumprod gb.dtype gb.first gb.groups gb.hist gb.max gb.min gb.nth gb.prod gb.resample gb.sum gb.var
gb.apply gb.cummax gb.cumsum gb.fillna gb.gender gb.head gb.indices gb.mean gb.name gb.ohlc gb.quantile gb.size gb.tail gb.weight
gb.apply gb.cummax gb.cumsum gb.gender gb.head gb.indices gb.mean gb.name gb.ohlc gb.quantile gb.size gb.tail gb.weight

.. _groupby.multiindex:

Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ or, if your formats are all ISO8601 (but possibly not identically-formatted) ::

Other API changes
^^^^^^^^^^^^^^^^^
- The ``freq``, ``tz``, ``nanosecond``, and ``unit`` keywords in the :class:`Timestamp` constructor are now keyword-only (:issue:`45307`, :issue:`32526`)
- The ``tz``, ``nanosecond``, and ``unit`` keywords in the :class:`Timestamp` constructor are now keyword-only (:issue:`45307`, :issue:`32526`)
- Passing ``nanoseconds`` greater than 999 or less than 0 in :class:`Timestamp` now raises a ``ValueError`` (:issue:`48538`, :issue:`48255`)
- :func:`read_csv`: specifying an incorrect number of columns with ``index_col`` of now raises ``ParserError`` instead of ``IndexError`` when using the c parser.
- Default value of ``dtype`` in :func:`get_dummies` is changed to ``bool`` from ``uint8`` (:issue:`45848`)
Expand Down
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v2.2.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Fixed regressions
- Fixed regression in :func:`merge_ordered` raising ``TypeError`` for ``fill_method="ffill"`` and ``how="left"`` (:issue:`57010`)
- Fixed regression in :func:`wide_to_long` raising an ``AttributeError`` for string columns (:issue:`57066`)
- Fixed regression in :meth:`DataFrame.loc` raising ``IndexError`` for non-unique, masked dtype indexes where result has more than 10,000 rows (:issue:`57027`)
- Fixed regression in :meth:`DataFrame.sort_index` not producing a stable sort for a index with duplicates (:issue:`57151`)
- Fixed regression in :meth:`DataFrame.to_dict` with ``orient='list'`` and datetime or timedelta types returning integers (:issue:`54824`)
- Fixed regression in :meth:`DataFrameGroupBy.idxmin`, :meth:`DataFrameGroupBy.idxmax`, :meth:`SeriesGroupBy.idxmin`, :meth:`SeriesGroupBy.idxmax` ignoring the ``skipna`` argument (:issue:`57040`)
- Fixed regression in :meth:`DataFrameGroupBy.idxmin`, :meth:`DataFrameGroupBy.idxmax`, :meth:`SeriesGroupBy.idxmin`, :meth:`SeriesGroupBy.idxmax` where values containing the minimum or maximum value for the dtype could produce incorrect results (:issue:`57040`)
- Fixed regression in :meth:`Index.join` raising ``TypeError`` when joining an empty index to a non-empty index containing mixed dtype values (:issue:`57048`)
Expand All @@ -28,6 +30,7 @@ Fixed regressions

Bug fixes
~~~~~~~~~
- Fixed bug in :func:`pandas.api.interchange.from_dataframe` which was raising for empty inputs (:issue:`56700`)
- Fixed bug in :meth:`DataFrame.__getitem__` for empty :class:`DataFrame` with Copy-on-Write enabled (:issue:`57130`)

.. ---------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ Deprecations
- Deprecated :meth:`Timestamp.utcnow`, use ``Timestamp.now("UTC")`` instead (:issue:`56680`)
-

.. ---------------------------------------------------------------------------
.. _whatsnew_300.prior_deprecations:

Removal of prior version deprecations/changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Removed :meth:`DataFrameGroupby.fillna` and :meth:`SeriesGroupBy.fillna` (:issue:`55719`)
- Removed ``axis`` argument from all groupby operations (:issue:`50405`)
- Removed deprecated argument ``obj`` in :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` (:issue:`53545`)

.. ---------------------------------------------------------------------------
.. _whatsnew_300.performance:

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:

# build dependencies
- versioneer[toml]
- cython=3.0.5
- cython~=3.0.5
- meson[ninja]=1.2.1
- meson-python=0.13.1

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def argsort(
na_position : {'first', 'last'}, default 'last'
If ``'first'``, put ``NaN`` values at the beginning.
If ``'last'``, put ``NaN`` values at the end.
*args, **kwargs:
**kwargs
Passed through to :func:`numpy.argsort`.
Returns
Expand Down
9 changes: 9 additions & 0 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ class Categorical(NDArrayBackedExtensionArray, PandasObject, ObjectStringArrayMi
Methods
-------
from_codes
as_ordered
as_unordered
set_categories
rename_categories
reorder_categories
add_categories
remove_categories
remove_unused_categories
map
__array__
Raises
Expand Down
25 changes: 2 additions & 23 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
from pandas.errors import (
ChainedAssignmentError,
InvalidIndexError,
)
from pandas.errors.cow import (
_chained_assignment_method_msg,
_chained_assignment_msg,
_chained_assignment_warning_method_msg,
Expand Down Expand Up @@ -89,7 +91,6 @@
find_common_type,
infer_dtype_from_scalar,
invalidate_string_dtypes,
maybe_box_native,
maybe_downcast_to_dtype,
)
from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -1987,28 +1988,6 @@ def to_numpy(

return result

def _create_data_for_split_and_tight_to_dict(
self, are_all_object_dtype_cols: bool, object_dtype_indices: list[int]
) -> list:
"""
Simple helper method to create data for to ``to_dict(orient="split")`` and
``to_dict(orient="tight")`` to create the main output data
"""
if are_all_object_dtype_cols:
data = [
list(map(maybe_box_native, t))
for t in self.itertuples(index=False, name=None)
]
else:
data = [list(t) for t in self.itertuples(index=False, name=None)]
if object_dtype_indices:
# If we have object_dtype_cols, apply maybe_box_naive after list
# comprehension for perf
for row in data:
for i in object_dtype_indices:
row[i] = maybe_box_native(row[i])
return data

@overload
def to_dict(
self,
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
InvalidIndexError,
SettingWithCopyError,
SettingWithCopyWarning,
)
from pandas.errors.cow import (
_chained_assignment_method_msg,
_chained_assignment_warning_method_msg,
_check_cacher,
Expand Down Expand Up @@ -9055,7 +9057,7 @@ def clip(
For `Series` this parameter is unused and defaults to `None`.
inplace : bool, default False
Whether to perform the operation in place on the data.
*args, **kwargs
**kwargs
Additional keywords have no effect but might be accepted
for compatibility with numpy.
Expand Down
1 change: 0 additions & 1 deletion pandas/core/groupby/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class OutputKey:
"cumsum",
"diff",
"ffill",
"fillna",
"ngroup",
"pct_change",
"rank",
Expand Down
Loading

0 comments on commit 65ac7cc

Please sign in to comment.