id
int64
number
int64
title
string
state
string
created_at
timestamp[s]
updated_at
timestamp[s]
closed_at
timestamp[s]
html_url
string
is_pull_request
bool
pull_request_url
string
pull_request_html_url
string
user_login
string
comments_count
int64
body
string
labels
list
reactions_plus1
int64
reactions_minus1
int64
reactions_laugh
int64
reactions_hooray
int64
reactions_confused
int64
reactions_heart
int64
reactions_rocket
int64
reactions_eyes
int64
comments
list
2,129,318,197
57,372
DEPR: Positional arguments in Series.to_markdown
closed
2024-02-12T02:18:44
2024-02-18T22:00:20
2024-02-18T21:57:38
https://github.com/pandas-dev/pandas/pull/57372
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57372
https://github.com/pandas-dev/pandas/pull/57372
rmhowe425
4
- [X] closes #57280 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [x] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [X] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "IO Data", "Deprecate" ]
0
0
0
0
0
0
0
0
[ "@mroeschke Pinging on green", "Looks good to me!\r\n\r\nIf you want to, you can also add overloads that already use the keyword-only syntax:\r\n\r\n\r\n```py\r\n @overload\r\n def to_markdown(\r\n self,\r\n buf: None = ...,\r\n *,\r\n mode: str = ...,\r\n index: bool = ...,\r\n storage_options: StorageOptions | None = ...,\r\n **kwargs,\r\n ) -> str: ...\r\n\r\n @overload\r\n def to_markdown(\r\n self,\r\n buf: IO[str],\r\n *,\r\n mode: str = ...,\r\n index: bool = ...,\r\n storage_options: StorageOptions | None = ...,\r\n **kwargs,\r\n ) -> None: ...\r\n\r\n @overload\r\n def to_markdown(\r\n self,\r\n buf: IO[str] | None,\r\n *,\r\n mode: str = ...,\r\n index: bool = ...,\r\n storage_options: StorageOptions | None = ...,\r\n **kwargs,\r\n ) -> str | None: ...\r\n```\r\n", "The changes look good to me, but the doc-test is failing (@mroeschke). The doc-test should definitely succeed before merging as the typing tests run after the doc-tests (in case mypy/pyright pick up something).", "Thank you @rmhowe425 !" ]
2,129,191,521
57,371
Remove close from StataReader
closed
2024-02-11T22:05:23
2024-02-12T17:15:14
2024-02-12T17:11:32
https://github.com/pandas-dev/pandas/pull/57371
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57371
https://github.com/pandas-dev/pandas/pull/57371
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "IO Stata" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,129,181,350
57,370
Remove use_nullable_dtypes from read_parquet
closed
2024-02-11T21:39:16
2024-02-12T17:15:23
2024-02-12T17:13:13
https://github.com/pandas-dev/pandas/pull/57370
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57370
https://github.com/pandas-dev/pandas/pull/57370
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "IO Parquet" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,129,179,202
57,369
Remove convert_dtype from Series.apply
closed
2024-02-11T21:33:40
2024-02-12T17:57:44
2024-02-12T17:56:55
https://github.com/pandas-dev/pandas/pull/57369
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57369
https://github.com/pandas-dev/pandas/pull/57369
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,129,133,223
57,368
CoW: Remove more using_copy_on_write fixtures
closed
2024-02-11T19:27:36
2024-02-12T17:20:19
2024-02-12T17:19:43
https://github.com/pandas-dev/pandas/pull/57368
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57368
https://github.com/pandas-dev/pandas/pull/57368
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,129,122,069
57,367
CoW: Remove Copy-on-Write fixtures from more tests
closed
2024-02-11T18:59:29
2024-02-12T17:21:16
2024-02-12T17:20:54
https://github.com/pandas-dev/pandas/pull/57367
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57367
https://github.com/pandas-dev/pandas/pull/57367
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,129,076,533
57,366
Potential regression induced by PR #56037
open
2024-02-11T17:05:09
2025-06-02T17:09:57
null
https://github.com/pandas-dev/pandas/issues/57366
true
null
null
rhshadrach
4
PR #56037 may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. - [inference.ToDatetimeFromIntsFloats.time_nanosec_float64](https://asv-runner.github.io/asv-collection/pandas/#inference.ToDatetimeFromIntsFloats.time_nanosec_float64) - [inference.ToDatetimeFromIntsFloats.time_sec_float64](https://asv-runner.github.io/asv-collection/pandas/#inference.ToDatetimeFromIntsFloats.time_sec_float64) Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. https://github.com/pandas-dev/pandas/compare/05c32ba18f88921b78dc5984c70956247497ab4c...d9f70b397a010754ae41e7d201bba05834294559 cc @jbrockmendel
[ "Performance", "Regression", "Non-Nano" ]
1
0
0
0
0
0
0
0
[ "My local asv benchmarking shows the regression was introduced in d9f70b3 rather than the previous commits\r\n\r\n```\r\n(venv) ➜ asv_bench git:(d9f70b397a) asv continuous -f 1.1 -E virtualenv HEAD~ HEAD -b inference.ToDatetimeFromIntsFloats.time_ Couldn't load asv.plugins._mamba_helpers because No module named 'libmambapy' · Creating environments · Discovering benchmarks ·· Uninstalling from virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter. ·· Installing d9f70b39 <v2.3.0.dev0~271> into virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter. · Running 12 total benchmarks (2 commits * 1 environments * 6 benchmarks) [ 0.00%] · For pandas commit e37ff77b <v2.3.0.dev0~272> (round 1/2): [ 0.00%] ·· Building for virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter..\r\n[ 0.00%] ·· Benchmarking virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter [ 4.17%] ··· Running (inference.ToDatetimeFromIntsFloats.time_nanosec_float64--)...... [25.00%] · For pandas commit d9f70b39 <v2.3.0.dev0~271> (round 1/2): [25.00%] ·· Building for virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter..\r\n[25.00%] ·· Benchmarking virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter\r\n[29.17%] ··· Running (inference.ToDatetimeFromIntsFloats.time_nanosec_float64--)...... [50.00%] · For pandas commit d9f70b39 <v2.3.0.dev0~271> (round 2/2): [50.00%] ·· Benchmarking virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter\r\n[54.17%] ··· inference.ToDatetimeFromIntsFloats.time_nanosec_float64 260±3ms\r\n[58.33%] ··· inference.ToDatetimeFromIntsFloats.time_nanosec_int64 3.16±0.09ms\r\n[62.50%] ··· inference.ToDatetimeFromIntsFloats.time_nanosec_uint64 3.03±0.2ms [66.67%] ··· inference.ToDatetimeFromIntsFloats.time_sec_float64 262±2ms [70.83%] ··· inference.ToDatetimeFromIntsFloats.time_sec_int64 31.1±0.3ms\r\n[75.00%] ··· inference.ToDatetimeFromIntsFloats.time_sec_uint64 30.9±0.2ms\r\n[75.00%] · For pandas commit e37ff77b <v2.3.0.dev0~272> (round 2/2):\r\n[75.00%] ·· Building for virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter..\r\n[75.00%] ·· Benchmarking virtualenv-py3.10-Cython3.0.5-jinja2-matplotlib-meson-meson-python-numba-numexpr-odfpy-openpyxl-pyarrow-python-build-scipy-sqlalchemy-tables-xlrd-xlsxwriter\r\n[79.17%] ··· inference.ToDatetimeFromIntsFloats.time_nanosec_float64 6.17±0.3ms\r\n[83.33%] ··· inference.ToDatetimeFromIntsFloats.time_nanosec_int64 2.93±0.06ms\r\n[87.50%] ··· inference.ToDatetimeFromIntsFloats.time_nanosec_uint64 2.91±0.06ms\r\n[91.67%] ··· inference.ToDatetimeFromIntsFloats.time_sec_float64 5.51±0.3ms\r\n[95.83%] ··· inference.ToDatetimeFromIntsFloats.time_sec_int64 31.0±0.3ms\r\n[100.00%] ··· inference.ToDatetimeFromIntsFloats.time_sec_uint64 30.9±0.08ms\r\n| Change | Before [e37ff77b] <v2.3.0.dev0~272> | After [d9f70b39] <v2.3.0.dev0~271> | Ratio | Benchmark (Parameter) |\r\n|----------|---------------------------------------|--------------------------------------|---------|---------------------------------------------------------|\r\n| + | 5.51±0.3ms | 262±2ms | 47.56 | inference.ToDatetimeFromIntsFloats.time_sec_float64 |\r\n| + | 6.17±0.3ms | 260±3ms | 42.2 | inference.ToDatetimeFromIntsFloats.time_nanosec_float64 |\r\n\r\nSOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.\r\nPERFORMANCE DECREASED.\r\n```", "Thanks @rtlee9 - isn't that commit associated with the highlighted PR in the OP?", "Yeah I was just confirming it was that commit in particular, since the asv benchmarks had skipped a few commits\r\n\r\n> Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified.\r\n", "Ah - thanks for confirming." ]
2,129,065,257
57,365
Update Styler documentation for escaping HTML
closed
2024-02-11T16:38:59
2024-02-21T18:00:02
2024-02-21T17:59:55
https://github.com/pandas-dev/pandas/pull/57365
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57365
https://github.com/pandas-dev/pandas/pull/57365
TomAugspurger
3
Adds a note to the docs about `Styler` and `escape` on untrusted HTML input.
[ "Docs", "IO HTML", "Styler" ]
0
0
0
0
0
0
0
0
[ "/preview", "LGTM", "Thanks @TomAugspurger " ]
2,129,050,935
57,364
CoW: Remove item_cache benchmarks
closed
2024-02-11T16:05:32
2024-02-12T17:23:29
2024-02-12T17:21:50
https://github.com/pandas-dev/pandas/pull/57364
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57364
https://github.com/pandas-dev/pandas/pull/57364
phofl
1
Those don't make sense anymore
[ "Benchmark", "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,129,001,355
57,363
Remove DataFrame.swapaxes
closed
2024-02-11T14:04:32
2024-03-07T15:35:24
2024-02-12T17:23:39
https://github.com/pandas-dev/pandas/pull/57363
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57363
https://github.com/pandas-dev/pandas/pull/57363
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,128,995,613
57,362
BUG: to_latex() does not escape index name
closed
2024-02-11T13:48:28
2025-04-28T16:58:42
2025-04-28T16:58:42
https://github.com/pandas-dev/pandas/issues/57362
true
null
null
bileamScheuvens
4
### Pandas version checks - [ ] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd pd.DataFrame({'_A': [1], '_B': ['a']}).set_index("_A").to_latex(escape=True) # produces: '\\begin{tabular}{ll}\n\\toprule\n & \\_B \\\\\n_A & \\\\\n\\midrule\n1 & a \\\\\n\\bottomrule\n\\end{tabular}\n' ``` ### Issue Description The resulting table includes the raw index name, instead of escaping properly. ### Expected Behavior ```Python import pandas as pd pd.DataFrame({'_A': [1], '_B': ['a']}).set_index("_A").to_latex(escape=True) >>'\\begin{tabular}{ll}\n\\toprule\n & \\_B \\\\\n\_A & \\\\\n\\midrule\n1 & a \\\\\n\\bottomrule\n\\end{tabular}\n' ``` ### Installed Versions INSTALLED VERSIONS ------------------ commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.10.8.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22631 machine : AMD64 processor : Intel64 Family 6 Model 183 Stepping 1, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : de_DE.cp1252 pandas : 2.2.0 numpy : 1.26.2 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 23.1.2 Cython : None pytest : 8.0.0 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 5.0.1 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.20.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2023.12.2 gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.11.4 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None
[ "Bug", "IO LaTeX", "Styler" ]
0
0
0
0
0
0
0
0
[ "duplicated: #47489 ", "closest fix: #48936 ", "This can be fixed with \r\n```py\r\ndf1.to_latex(escape=True)\r\n```\r\n\r\nThe document says\r\n\r\n> By default, the value will be read from the pandas config module and set to True if the option styler.format.escape is “latex”. When set to False prevents from escaping latex special characters in column names.\r\n> Changed in version 2.0.0: The pandas option affecting this argument has changed, as has the default value to False.\r\n\r\nDon't know why this relies on `styler.format.escape`. But default to True would be more sensible imo.\r\n\r\n", "> This can be fixed with\r\n> \r\n> ```python\r\n> df1.to_latex(escape=True)\r\n> ```\r\n\r\nDid you test this? The example includes \r\n\r\n```python \r\nescape=True\r\n```\r\n\r\n#47489 goes into more detail, this is definitely an issue. " ]
2,128,994,702
57,361
Remove support for errors="ignore" in to_datetime, to_timedelta and to_numeric
closed
2024-02-11T13:45:38
2024-02-12T17:29:43
2024-02-12T17:29:17
https://github.com/pandas-dev/pandas/pull/57361
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57361
https://github.com/pandas-dev/pandas/pull/57361
phofl
1
- [ ] closes #55734 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,128,952,983
57,360
CI/DOC: Enforce GL08 in CI
closed
2024-02-11T11:41:16
2024-02-15T21:28:01
2024-02-15T21:20:22
https://github.com/pandas-dev/pandas/pull/57360
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57360
https://github.com/pandas-dev/pandas/pull/57360
jordan-d-murphy
3
Enforce GL08 in CI so that it can be fixed and enforced in chunks like other docstring errors. The added functions come from the result of running `scripts/validate_docstrings.py --format=actions --errors=GL08` Part of our ongoing work to continue enforcing numpydoc validations: https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks - [x] xref https://github.com/pandas-dev/pandas/pull/56971 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "CI" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n", "@mroeschke merge conflicts resolved in code_checks\r\nthis is the last one! \r\n", "Thanks @jordan-d-murphy " ]
2,128,947,494
57,359
CI/DOC: Enforce ES01 in CI
closed
2024-02-11T11:24:03
2024-02-15T19:59:13
2024-02-15T19:50:30
https://github.com/pandas-dev/pandas/pull/57359
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57359
https://github.com/pandas-dev/pandas/pull/57359
jordan-d-murphy
5
Enforce ES01 in CI so that it can be fixed and enforced in chunks like other docstring errors. The added functions come from the result of running `scripts/validate_docstrings.py --format=actions --errors=ES01` Part of our ongoing work to continue enforcing numpydoc validations: https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks - [x] xref https://github.com/pandas-dev/pandas/pull/56971 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "CI" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n", "@mroeschke the merge conflicts in code_checks have been resolved\r\n", "Thanks @jordan-d-murphy ", "okay - thanks for the heads up. Always happy to adjust and redirect effort elsewhere as needed. I certainly appreciate the speedy reviews and helpful suggestions! ", "In the end it's open source and any contribution of yours is welcome :)\r\n\r\n_Personally_ I find fixing the docs to enforce these rules is a bit more externally useful than enforcing some of the missing rules in the CI (since pandas doesn't not add new APIs with docs often anymore)" ]
2,128,944,030
57,358
CI/DOC: Enforce PR01 in CI
closed
2024-02-11T11:12:27
2024-02-14T22:02:02
2024-02-14T19:43:21
https://github.com/pandas-dev/pandas/pull/57358
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57358
https://github.com/pandas-dev/pandas/pull/57358
jordan-d-murphy
3
Enforce PR01 in CI so that it can be fixed and enforced in chunks like other docstring errors. The added functions come from the result of running `scripts/validate_docstrings.py --format=actions --errors=PR01` Part of our ongoing work to continue enforcing numpydoc validations: https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks - [x] xref https://github.com/pandas-dev/pandas/pull/56971 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "CI" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n", "@mroeschke merge conflicts have been resolved in code_checks.sh", "Almost there!" ]
2,128,938,515
57,357
CI/DOC: Enforce PR07 in CI
closed
2024-02-11T10:54:30
2024-02-14T17:26:33
2024-02-14T15:04:47
https://github.com/pandas-dev/pandas/pull/57357
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57357
https://github.com/pandas-dev/pandas/pull/57357
jordan-d-murphy
3
Enforce PR07 in CI so that it can be fixed and enforced in chunks like other docstring errors. The added functions come from the result of running `scripts/validate_docstrings.py --format=actions --errors=PR07` Part of our ongoing work to continue enforcing numpydoc validations: https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks - [x] xref https://github.com/pandas-dev/pandas/pull/56971 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "CI" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n", "@mroeschke I've resolved the merge conflicts in code_checks.sh for this PR", "Thank you @jordan-d-murphy" ]
2,128,933,500
57,356
CI/DOC: Enforce RT03 in CI
closed
2024-02-11T10:38:10
2024-02-14T03:00:25
2024-02-14T02:14:17
https://github.com/pandas-dev/pandas/pull/57356
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57356
https://github.com/pandas-dev/pandas/pull/57356
jordan-d-murphy
3
Enforce RT03 in CI so that it can be fixed and enforced in chunks like other docstring errors. The added functions come from the result of running `scripts/validate_docstrings.py --format=actions --errors=RT03` Part of our ongoing work to continue enforcing numpydoc validations: https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks - [x] xref https://github.com/pandas-dev/pandas/pull/56971 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Code Style" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix", "@mroeschke merge conflicts have been resolved ", "Thanks @jordan-d-murphy " ]
2,128,933,210
57,355
BUG: the `seconds` attribute of `.dt.components` for pyarrow timestamp datatype seem faulty
closed
2024-02-11T10:37:22
2024-06-18T18:22:39
2024-06-18T18:22:39
https://github.com/pandas-dev/pandas/issues/57355
true
null
null
MatusGasparik
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd assert pd.__version__ == '2.2.0' # example from the book "Effective Pandas 2 (by Matt Harrison)" classes = ['cs106', 'cs150', 'hist205', 'hist206', 'hist207'] start_dates = ( pd.Series([ '2015-03-08', '2015-03-08', '2015-03-09', '2015-03-09', '2015-03-11' ], dtype='datetime64[ns]', index=classes ).astype('timestamp[ns][pyarrow]')) end_dates = ( pd.Series([ '2015-05-28 23:59:59', '2015-06-01 3:00:00', '2015-06-03', '2015-06-02 14:20', '2015-06-01' ], dtype='datetime64[ns]', index=classes ).astype('timestamp[ns][pyarrow]')) duration = (end_dates - start_dates) ``` ### Issue Description These are the data: ```python print(duration) ``` ``` cs106 81 days 23:59:59 cs150 85 days 03:00:00 hist205 86 days 00:00:00 hist206 85 days 14:20:00 hist207 82 days 00:00:00 dtype: duration[ns][pyarrow] ``` I noticed that calling `.dt.components` on the above duration object behaves differently for the `'timestamp[ns][pyarrow]'` vs. the `'timedelta64[ns]'` data types. For the former, the `seconds` attribute (column) give a very high value (and I assume it is total seconds for the 'HH:MM:SS' part. ```python print(duration.dt.components) ``` results in: ``` days hours minutes seconds milliseconds microseconds nanoseconds 0 81 23 59 86399 0 0 0 1 85 3 0 10800 0 0 0 2 86 0 0 0 0 0 0 3 85 14 20 51600 0 0 0 4 82 0 0 0 0 0 0 ``` ### Expected Behavior Converting to pandas 1.x `'timedelta64[ns]'` give an expected result: ```python print(duration.astype('timedelta64[ns]').dt.components) ``` results in: ``` days hours minutes seconds milliseconds microseconds nanoseconds cs106 81 23 59 59 0 0 0 cs150 85 3 0 0 0 0 0 hist205 86 0 0 0 0 0 0 hist206 85 14 20 0 0 0 0 hist207 82 0 0 0 0 0 0 ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.12.1.final.0 python-bits : 64 OS : Darwin OS-release : 21.6.0 Version : Darwin Kernel Version 21.6.0: Sun Nov 6 23:31:13 PST 2022; root:xnu-8020.240.14~1/RELEASE_ARM64_T6000 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : de_DE.UTF-8 LOCALE : de_DE.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 24.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None </details>
[ "Bug", "datetime.date", "Arrow" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. Confirmed on main, further investigations and PRs to fix are welcome!", "Will try to work on this.", "take" ]
2,128,918,987
57,354
CI/DOC: Enforce SA01 in CI
closed
2024-02-11T09:50:59
2024-02-13T20:05:13
2024-02-13T19:57:48
https://github.com/pandas-dev/pandas/pull/57354
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57354
https://github.com/pandas-dev/pandas/pull/57354
jordan-d-murphy
3
Enforce SA01 in CI so that it can be fixed and enforced in chunks like other docstring errors. The added functions come from the result of running `scripts/validate_docstrings.py --format=actions --errors=SA01` Part of our ongoing work to continue enforcing numpydoc validations: https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks - [x] xref https://github.com/pandas-dev/pandas/pull/56971 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "CI" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix", "@mroeschke I resolved the merge conflicts in code_checks.sh \n\ncan you take a look at this PR? \n\nI opened several similar PRe for each of the outstanding numpy doc validation errors. each time we merge one it will cause conflicts with the rest, but I'll go through and update them one at a time to resolve the merge conflicts ", "Thanks @jordan-d-murphy " ]
2,128,915,201
57,353
DOC: Add missing doc `Index.array` and `Index.to_numpy`
closed
2024-02-11T09:39:01
2024-02-12T08:46:24
2024-02-11T13:06:46
https://github.com/pandas-dev/pandas/pull/57353
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57353
https://github.com/pandas-dev/pandas/pull/57353
luke396
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. As https://github.com/pandas-dev/pandas/pull/57029#issuecomment-1935456363 and #57016, it appears that we are lacking some API references. I'm interested in conducting a thorough check for any additional missing documentation, but haven't been able to identify a consistent pattern in the missing documentation. Do we have any other suggestions other than comparing the different versions one by one?
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "thx @luke396 " ]
2,128,896,895
57,352
CI/DOC: Enforce SA05 in CI
closed
2024-02-11T08:43:46
2024-02-12T18:34:55
2024-02-12T18:33:29
https://github.com/pandas-dev/pandas/pull/57352
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57352
https://github.com/pandas-dev/pandas/pull/57352
jordan-d-murphy
2
Enforce SA05 in CI so that it can be fixed and enforced in chunks like other docstring errors. The added functions come from the result of running `scripts/validate_docstrings.py --format=actions --errors=SA05` Part of our ongoing work to continue enforcing numpydoc validations: https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks - [x] xref https://github.com/pandas-dev/pandas/pull/56971 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Code Style" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix", "Thanks @jordan-d-murphy " ]
2,128,840,418
57,351
BUG: FutureWarning when splitting a dataframe using `np.split`
open
2024-02-11T05:12:44
2025-08-17T02:23:14
null
https://github.com/pandas-dev/pandas/issues/57351
true
null
null
amanlai
13
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python To reproduce it: import numpy as np import pandas as pd df = pd.DataFrame({'a': [1, 2, 3]}) lst = np.split(df, 3) ``` ### Issue Description The above code raises a FutureWarning: ```none FutureWarning: 'DataFrame.swapaxes' is deprecated and will be removed in a future version. Please use 'DataFrame.transpose' instead. ``` As far as I understand, `np.split` uses `np.swapaxes` which is raising this warning. ### Expected Behavior Not show a warning. ### Installed Versions <details> python : 3.11.5 pandas : 2.2.0 numpy : 1.26.3 </details>
[ "Regression", "Compat", "Blocker", "Deprecate", "ufuncs" ]
0
0
0
0
0
0
0
0
[ "`swapaxes` is called from shape_base.py in numpy package", "Thanks for the report - is there a reason you prefer to use `np.swapaxes(df)` over `df.T`?", "@rhshadrach the use case here is not `np.swapaxes(df)` itself, it's `np.split(df)`, which apparently uses `np.swapaxes` under the hood.", "Ah, thanks @amanlai. On main, `DataFrame.swapaxes` has been removed and the OP gives the output:\r\n\r\n```[array([[1]]), array([[2]]), array([[3]])]```\r\n\r\nOn 2.2.x, I am seeing\r\n\r\n```\r\n[ a\r\n0 1, a\r\n1 2, a\r\n2 3]\r\n```\r\n\r\ncc @jorisvandenbossche @phofl @mroeschke ", "Marking this as a blocker for 3.0 so a decision is made.", "I don't think many people use `np.split` on a DataFrame to consider reverting this deprecation. ([Stackoverflow question](https://stackoverflow.com/questions/77576750/futurewarning-dataframe-swapaxes-is-deprecated-and-will-be-removed-in-a-futur) did not have many interactions)\r\n\r\nAnd as stated in [numpy/numpy#24889 (comment)](https://github.com/numpy/numpy/issues/24889#issuecomment-1895503977) it's possible to calculate the start/stop slices and then manually slicing using `df.iloc[start:stop]`", "I agree with @Aloqeely. Is there an upstream issue for NumPy on this topic? I think should be resolved there and use `df.T` like @rhshadrach suggests", "Ah ignore my previous comment - I thought they were calling our swapaxes implementation but misread the OP. Assuming they call swapaxes generically for their internal use, so not as easy as changing the call\r\n\r\nEven still I don't think we should revert this deprecation", "Is it sensible to implement a `DataFrame.split` function for convenience? Since `np.split` doesn't work appropriately on DataFrames anymore.\n\nI can work on it next week if you are all ok with it.", "> Is there an upstream issue for NumPy on this topic?\r\n\r\nhttps://github.com/numpy/numpy/issues/24889#issuecomment-1895503977", "> Is it sensible to implement a `DataFrame.split` function for convenience? Since `np.split` doesn't work appropriately on DataFrames anymore.\r\n\r\nI don't think so - generally our goal is to reduce the footprint of our API, and I don't see this as a huge value add over the other method you have suggested:\r\n\r\n> And as stated in [numpy/numpy#24889 (comment)](https://github.com/numpy/numpy/issues/24889#issuecomment-1895503977) it's possible to calculate the start/stop slices and then manually slicing using `df.iloc[start:stop]`\r\n\r\n", "> Is it sensible to implement a `DataFrame.split` function for convenience? Since `np.split` doesn't work appropriately on DataFrames anymore.\r\n> \r\n> I can work on it next week if you are all ok with it.\r\n\r\n+1 :+1: splitting a dataframe into equally sized chunks (except for the trailing chunk) is a routine task in ML and other batching applications.\r\n\r\nrequiring end-users to replace np.split/np.array_split with some bespoke `iloc` helper function sounds to me like a lot of duplicated boilerplate, wasted brain cycles over time, and overall increased bug surface for the ecosystem ", "another big reason to use np.array_split is the optional `axis=1` argument, which is probably why it is calling `np.swapaxes` in the first place." ]
2,128,782,275
57,350
DOC: fix PR02 errors in docstring for pandas.tseries.offsets.DateOffset
closed
2024-02-11T01:09:13
2024-02-13T02:41:48
2024-02-13T02:41:44
https://github.com/pandas-dev/pandas/pull/57350
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57350
https://github.com/pandas-dev/pandas/pull/57350
jordan-d-murphy
2
All PR02 errors resolved for the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=PR02 pandas.tseries.offsets.DateOffset - [x] xref https://github.com/pandas-dev/pandas/issues/57111 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix", "pre-commit.ci autofix\r\n\r\n" ]
2,128,778,385
57,349
BUG: Out of bounds nanosecond timestamp when s was specified
closed
2024-02-11T00:53:38
2024-05-31T18:40:08
2024-05-31T18:40:07
https://github.com/pandas-dev/pandas/issues/57349
true
null
null
khider
1
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd import numpy as np ser_index = pd.DatetimeIndex([ np.datetime64('0000-01-01', 's'), np.datetime64('2000-01-01', 's'), ]) ``` ### Issue Description Traceback (most recent call last): Cell In[1], line 1 ser_index = pd.DatetimeIndex([ NameError: name 'pd' is not defined import pandas as pd import numpy as np ser_index = pd.DatetimeIndex([ np.datetime64('0000-01-01', 's'), np.datetime64('2000-01-01', 's'), ]) Traceback (most recent call last): File conversion.pyx:294 in pandas._libs.tslibs.conversion.get_datetime64_nanos OverflowError: Overflow occurred in npy_datetimestruct_to_datetime The above exception was the direct cause of the following exception: Traceback (most recent call last): Cell In[4], line 1 ser_index = pd.DatetimeIndex([ File ~/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/pandas/core/indexes/datetimes.py:370 in __new__ dtarr = DatetimeArray._from_sequence_not_strict( File ~/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py:369 in _from_sequence_not_strict subarr, tz = _sequence_to_dt64( File ~/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py:2248 in _sequence_to_dt64 converted, inferred_tz = objects_to_datetime64( File ~/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py:2398 in objects_to_datetime64 result, tz_parsed = tslib.array_to_datetime( File tslib.pyx:414 in pandas._libs.tslib.array_to_datetime File tslib.pyx:596 in pandas._libs.tslib.array_to_datetime File tslib.pyx:520 in pandas._libs.tslib.array_to_datetime File conversion.pyx:297 in pandas._libs.tslibs.conversion.get_datetime64_nanos OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 0000-01-01T00:00:00, at position 0 ### Expected Behavior Used to work as of 2.0.4. ### Installed Versions <details> /Users/deborahkhider/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.") INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.10.8.final.0 python-bits : 64 OS : Darwin OS-release : 22.6.0 Version : Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:56 PDT 2023; root:xnu-8796.141.3~6/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.0 numpy : 1.24.3 pytz : 2023.3 dateutil : 2.8.2 setuptools : 67.7.2 pip : 23.1.2 Cython : 0.29.33 pytest : None hypothesis : None sphinx : 5.0.2 blosc : None feather : None xlsxwriter : None lxml.etree : 4.9.2 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.14.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : 1.3.6 dataframe-api-compat : None fastparquet : None fsspec : 2023.6.0 gcsfs : None matplotlib : 3.6.3 numba : 0.57.0 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.12.0 sqlalchemy : 2.0.23 tables : None tabulate : 0.9.0 xarray : 2023.1.0 xlrd : 2.0.1 zstandard : None tzdata : 2023.3 qtpy : 2.3.1 pyqt5 : None </details>
[ "Bug", "Non-Nano" ]
0
0
0
0
0
0
0
0
[ "Should be fixed by #55901" ]
2,128,774,611
57,348
Remove fillna from Resampler
closed
2024-02-11T00:38:49
2024-02-12T17:40:08
2024-02-12T17:40:05
https://github.com/pandas-dev/pandas/pull/57348
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57348
https://github.com/pandas-dev/pandas/pull/57348
phofl
0
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Resample" ]
0
0
0
0
0
0
0
0
[]
2,128,771,199
57,347
CoW: Deprecate copy keyword from first set of methods
closed
2024-02-11T00:26:01
2024-02-24T19:12:38
2024-02-24T18:31:58
https://github.com/pandas-dev/pandas/pull/57347
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57347
https://github.com/pandas-dev/pandas/pull/57347
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Deprecate", "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,128,756,693
57,346
CoW: Remove a few copy=False statements
closed
2024-02-10T23:45:47
2024-02-12T17:08:31
2024-02-12T17:03:38
https://github.com/pandas-dev/pandas/pull/57346
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57346
https://github.com/pandas-dev/pandas/pull/57346
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,128,748,342
57,345
Remove DataFrame.applymap and Styler.applymap
closed
2024-02-10T23:10:23
2024-02-11T12:56:30
2024-02-11T12:56:28
https://github.com/pandas-dev/pandas/pull/57345
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57345
https://github.com/pandas-dev/pandas/pull/57345
phofl
0
- [ ] closes #52364 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "DataFrame", "Styler" ]
0
0
0
0
0
0
0
0
[]
2,128,745,682
57,344
Remove limit, fill_axis, broadcast_axis and method parameters from align
closed
2024-02-10T23:00:23
2024-02-13T17:34:27
2024-02-13T17:29:37
https://github.com/pandas-dev/pandas/pull/57344
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57344
https://github.com/pandas-dev/pandas/pull/57344
phofl
2
- [ ] closes #51968 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl ", "@simonjayhawkins please don't add the Deprecate label to deprecation enforcal PRs, we have a bot that tracks merged PRs with the Deprecate label to log Deprecations. " ]
2,128,742,374
57,343
Remove support for slices in take
closed
2024-02-10T22:47:19
2024-02-13T17:44:27
2024-02-13T17:44:02
https://github.com/pandas-dev/pandas/pull/57343
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57343
https://github.com/pandas-dev/pandas/pull/57343
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Indexing" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,128,741,183
57,342
Remove support for DataFrames from df.from_records
closed
2024-02-10T22:43:03
2024-02-13T17:33:00
2024-02-13T17:30:46
https://github.com/pandas-dev/pandas/pull/57342
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57342
https://github.com/pandas-dev/pandas/pull/57342
phofl
1
- [ ] closes #51697 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,128,727,229
57,341
REGR: assert_series_equal defaulting to check_exact=True for Index
closed
2024-02-10T21:57:53
2024-02-12T21:58:20
2024-02-12T18:23:20
https://github.com/pandas-dev/pandas/pull/57341
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57341
https://github.com/pandas-dev/pandas/pull/57341
phofl
1
- [ ] closes #57067 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Testing", "Regression" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,128,722,928
57,340
REGR: shift raising for axis=1 and empty df
closed
2024-02-10T21:41:44
2024-02-12T18:29:39
2024-02-12T18:25:28
https://github.com/pandas-dev/pandas/pull/57340
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57340
https://github.com/pandas-dev/pandas/pull/57340
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "DataFrame" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,128,715,040
57,339
Backport PR #57323 on branch 2.2.x (REGR: Fix regression when grouping over a Series)
closed
2024-02-10T21:10:48
2024-02-10T21:58:10
2024-02-10T21:58:10
https://github.com/pandas-dev/pandas/pull/57339
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57339
https://github.com/pandas-dev/pandas/pull/57339
meeseeksmachine
0
Backport PR #57323: REGR: Fix regression when grouping over a Series
[ "Regression", "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[]
2,128,670,938
57,338
BUG: Incompatible dype warning when assigning boolean series with logical indexer
closed
2024-02-10T19:10:16
2025-07-01T17:47:14
2025-07-01T17:47:13
https://github.com/pandas-dev/pandas/issues/57338
true
null
null
m0nzderr
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd data1 = pd.Series([True, True, True], dtype=bool) data2 = pd.Series([False, False, False], dtype=bool) condition = pd.Series([False, True, False], dtype=bool) data1[condition] = data2[condition] # > FutureWarning: Setting an item of incompatible dtype... ``` ### Issue Description The assignment ```data1[condition] = data2[condition] ``` results in warning claiming incompatible types: > FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in > a future version of pandas. Value '[False]' has dtype incompatible with bool, please > explicitly cast to a compatible dtype first. data1[condition] = data2[condition] > Which is clearly not true. This bug is somewhat related to the one reported in #56600, although the use case is different. Interestingly, the problem disappears when using another dtype, such as int (code below works as expected, no warnings) : ``` data1 = pd.Series([1 ,2, 3], dtype=int) data2 = pd.Series([4, 5, 6], dtype=int) condition = pd.Series([False, True, False], dtype=bool) data1[condition] = data2[condition] ``` Note: Reproduced on pandas==2.2.0 and 3.0.0.dev0+292.g70f367194a ### Expected Behavior There should be no warning. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : 70f367194aff043f4f9ca549003df8a2a97f286a python : 3.10.12.final.0 python-bits : 64 OS : Linux OS-release : 5.15.133.1-microsoft-standard-WSL2 Version : #1 SMP Thu Oct 5 21:02:42 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : None LOCALE : en_US.UTF-8 pandas : 3.0.0.dev0+292.g70f367194a numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 59.6.0 pip : 24.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.8.2 numba : None numexpr : None odfpy : None openpyxl : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.12.0 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None </details>
[ "Bug", "Indexing", "PDEP6-related" ]
0
0
0
0
0
0
0
0
[ "This actually upcasts to object, which means that the warning is kind of correct, but this should definitely work and continue to work.\r\n\r\nI suspect that we do a align under the hood that causes this, cc @MarcoGorelli ", "@phofl I'm not familiar with the implementation and have no idea about the reasons for the upcast, but, intuitively, I see no reason for that to happen. Both series already have the same dtype, so any conversion would be unnecessary. It is also very counter-intuitive to have different behaviors among primitive types (i.e., no upcast in case of ints or floats, but an upcast in case of bools...).", "I think what's happening is that when we mask the series, we eventually try to set the items at the index ```array([1])``` to ```array([False])``` (which is the second element of data2). However, this array is an object type. When we try to cast this array to a bool, pandas gives a LossySetitemError, which may be the problem." ]
2,128,659,836
57,337
Backport PR #57333 on branch 2.2.x (REGR: merge with 3rd party EA's can sometimes raise ValueError)
closed
2024-02-10T18:58:54
2024-02-10T21:09:36
2024-02-10T21:09:36
https://github.com/pandas-dev/pandas/pull/57337
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57337
https://github.com/pandas-dev/pandas/pull/57337
lukemanley
0
#57333
[ "Reshaping", "Regression" ]
0
0
0
0
0
0
0
0
[]
2,128,341,218
57,336
Backport PR #57329 on branch 2.2.x (REGR: CategoricalIndex.difference with null values)
closed
2024-02-10T11:38:13
2024-02-10T15:06:36
2024-02-10T15:06:36
https://github.com/pandas-dev/pandas/pull/57336
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57336
https://github.com/pandas-dev/pandas/pull/57336
meeseeksmachine
0
Backport PR #57329: REGR: CategoricalIndex.difference with null values
[ "Regression", "Categorical", "setops" ]
0
0
0
0
0
0
0
0
[]
2,128,263,785
57,335
DEPR: pd.concat special cases DatetimeIndex to sort even when sort=False
open
2024-02-10T09:50:42
2025-08-14T16:36:24
null
https://github.com/pandas-dev/pandas/issues/57335
true
null
null
lukemanley
10
`pd.concat` has a specific behavior to always sort `DatetimeIndex` when `join="outer"` and the non-concatentation axes are not aligned. This was undocumented (prior to 2.2.1) and is inconsistent with all other index types and data types including other temporal types such as pyarrow timestamps/dates/times. An attempt to treat this as a bug fix highlighted that this has been long-standing behavior that users may be accustomed to. (xref #57006) Here are two options that come to mind: 1. Deprecate the existing behavior and do not sort by default for `DatetimeIndex`. This would simplify things by removing the carve out and treating all index types / data types consistently. This would require users to explicitly pass `sort=True` when concatenating two frames with monotonic indexes if they wanted to ensure a monotonic result. 2. Always sort the non-concatenation axis when `join="outer"` (for all dtypes). This would be consistent with how `pd.merge` and `DataFrame.join` handle outer merges and in practice may be more useful behavior since concatenating two frames with monotonic indexes will return a frame with a monotonic index.
[ "Reshaping", "Deprecate", "Needs Discussion", "Sorting" ]
0
0
0
0
0
0
0
0
[ "+1 on (1) - different sorting defaults for different dtypes is very surprising.\r\n\r\nFor (2), I do prefer concat's way of maintaining order by starting with the first frame and tacking on any new labels to the end as it proceeds through the list. When this order is desired, I think this behavior is harder for the user to replicate.", "My vote very much goes to option 2. Setting `sort=False` then should behave the way @rhshadrach describes his preferred concat behaviour. Though I really must say, I don't quite see how often that is useful in real-word examples. Given how much time series-related functionality is built into Pandas I'm surprised option 2 isn't considered the more reasonable use case. In all the applications I see Pandas used it's very rare to have a DataFrame with both \"label-style\" index and columns; usually one of the two is rather a time dimension. Maybe @rhshadrach can provide concrete real-world examples where the non-sorting behaviour is desireable on a true outer join? I personally can't think of any good ones...\r\n\r\nI'm more than happy however to provide a slew of examples of `concat` usage where one of the axes represents a time dimension and, consequently, maintaining sorting on an outer join along the other axis is paramount. Maybe however I'm using the wrong tool? I.e. should I be using `merge` in those cases?", "> In all the applications I see Pandas used it's very rare to have a DataFrame with both \"label-style\" index and columns; usually one of the two is rather a time dimension.\r\n\r\nI always use \"label-style\" index and columns.\r\n\r\n> Maybe @rhshadrach can provide concrete real-world examples where the non-sorting behaviour is desireable on a true outer join?\r\n\r\nAny DataFrame where the order of the rows/columns contains information, such as a sequence of events.\r\n\r\n> I'm more than happy however to provide a slew of examples of `concat` usage where one of the axes represents a time dimension and, consequently, maintaining sorting on an outer join along the other axis is paramount.\r\n\r\nAnd that is still quite easy to attain: `df.sort_index(axis=\"index\")` and `df.sort_index(axis=\"columns\")`. However, if we sorted the non-concatenating index by default, how would users get the alternative order back? That isn't so easy.", ">However, if we sorted the non-concatenating index by default, how would users get the alternative order back? That isn't so easy.\r\n\r\nBy using the `sort=False` argument in `pd.concat`, no? Indeed I'm not saying the sort kwarg should be ignored as it used to be, I'm just arguing that the default of sorting seems very reasonable to me in order to keep a vast majority of code short and sweet.\r\n\r\nThe label-only cases surely are out there, but given how much timeseries functionality has been built into Pandas I tend to be convinced that many usecases these days have a time dimension on one of the axes. For what it's worth, essentially all of mine do.\r\n\r\nAre you suggesting that otherwise anyone working almost exclusively with timeseries-like data will always have to invoke pd.concat with subsequent explicit sort calls? That seems rather verbose and error-prone to me. There surely then must be a better way to safely assemble DataFrames in such a setting; maybe concat is not the right thing to use?\r\n\r\n", "> By using the `sort=False` argument in `pd.concat`, no?\r\n\r\nPerhaps I'm misunderstanding. @lukemanley opened this issue with the line:\r\n\r\n> `pd.concat` has a specific behavior to always sort `DatetimeIndex` when `join=\"outer\"` and the non-concatentation axes are not aligned.\r\n\r\nThen presented two options to rectify the inconsistency. The first is to treat `DatetimeIndex` as all other dtypes are treated today. The second was:\r\n\r\n> Always sort the non-concatenation axis when join=\"outer\" (for all dtypes). \r\n\r\nand this is the one you agreed with in https://github.com/pandas-dev/pandas/issues/57335#issuecomment-1946115289. Perhaps \"always\" doesn't mean what I think it means?\r\n\r\n> Are you suggesting that otherwise anyone working almost exclusively with timeseries-like data will always have to invoke pd.concat with subsequent explicit sort calls?\r\n\r\nNo - `sort=True` will still sort.\r\n", "Rereading your previous comment, it seems to me you're advocating changing the default of `sort` in concat to `True` across the board for all dtypes. If that's the case, I think it should be discussed in a separate issue - this one is about rectifying a specific inconsistency with DatetimeIndex.\r\n\r\nIf, on the other hand, you're advocating for a dtype-dependent sorting default (`sort=True` for DatetimeIndex, `False` for other dtypes), then I think this is too complex and surprising of a default.", "> Perhaps \"always\" doesn't mean what I think it means?\r\n\r\nYeah was maybe not being clear here: by \"always\" I really meant when `sort=True` and to have that as the default, at least in the `DateTimeIndex` case.\r\n\r\n>If, on the other hand, you're advocating for a dtype-dependent sorting default (sort=True for DatetimeIndex, False for other dtypes), then I think this is too complex and surprising of a default.\r\n\r\nYeah I can see your point re. surprising behaviour and complexity here. I'd be quite content with `sort=True` by default across the board indeed. As I mentioned, `.groupby()` already has `sort=True` by default.\r\n\r\n> No - sort=True will still sort.\r\n\r\nSure, but unless one forgets to call that it will end up unsorted leading likely to failures that give erroneous results but without throwing an error, i.e. the worst kind of bug (again, coming form the timeseries perspective here). Putting what I'm saying differently: don't you think that sorting by default is safer than not sorting by default? Sure, the former might have unnecessary overheard in some cases, but those can be solved by then explicitly setting `sort=False`; the same goes for the cases where one wants to \"preserve\" order (i.e. the appending behaviour).\r\n\r\nCome to think of it, I would actually also argue that the behaviour of appending indices on the non-concatenation axis is not 100% transparent either: if `concat` is called on e.g. a dictionary, then one tends to think of that as an unsorted collection of elements to be concatenated, yet their implicit order will inlfuence the outcome of the non-concatenation axis when `sort=False`. You see what I mean?", "> I'd be quite content with `sort=True` by default across the board indeed. As I mentioned, `.groupby()` already has `sort=True` by default.\r\n\r\nAs mentioned above, I recommend opening a new issue if you'd like to pursue changing the default value of sort.", "@rhshadrach is this actionable for 3.0?", "I'm +1 on calling this a bugfix and having all dtypes respect the sort argument. -1 on changing sort defaults without a proposal that considers the entire API." ]
2,128,210,740
57,334
DOC: fix PR02 errors in docstring for pandas.core.groupby.DataFrameGroupBy.rolling and pandas.core.groupby.SeriesGroupBy.rolling
closed
2024-02-10T08:12:44
2024-02-12T18:32:45
2024-02-12T18:30:55
https://github.com/pandas-dev/pandas/pull/57334
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57334
https://github.com/pandas-dev/pandas/pull/57334
jordan-d-murphy
1
All PR02 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=PR02 pandas.core.groupby.DataFrameGroupBy.rolling 2. scripts/validate_docstrings.py --format=actions --errors=PR02 pandas.core.groupby.SeriesGroupBy.rolling - [x] xref https://github.com/pandas-dev/pandas/issues/57111 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "Code Style" ]
0
0
0
0
0
0
0
0
[ "Thanks @jordan-d-murphy " ]
2,128,062,876
57,333
REGR: merge with 3rd party EA's can sometimes raise ValueError
closed
2024-02-10T02:56:36
2024-02-10T21:09:22
2024-02-10T16:18:45
https://github.com/pandas-dev/pandas/pull/57333
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57333
https://github.com/pandas-dev/pandas/pull/57333
lukemanley
2
- [x] closes #57316 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [x] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [x] Added an entry in the latest `doc/source/whatsnew/v2.2.1.rst` file if fixing a bug or adding a new feature.
[ "Reshaping", "Regression" ]
0
0
0
0
0
0
0
0
[ "Thx @lukemanley ", "Owee, I'm MrMeeseeks, Look at me.\n\nThere seem to be a conflict, please backport manually. Here are approximate instructions:\n\n1. Checkout backport branch and update it.\n\n```\ngit checkout 2.2.x\ngit pull\n```\n\n2. Cherry pick the first parent branch of the this PR on top of the older branch:\n```\ngit cherry-pick -x -m1 2e0ef79dd48b13045ff3539df895c3b647c25403\n```\n\n3. You will likely have some merge/cherry-pick conflict here, fix them and commit:\n\n```\ngit commit -am \"Backport PR #57333: REGR: merge with 3rd party EA's can sometimes raise ValueError\"\n```\n\n4. Push to a named branch:\n\n```\ngit push YOURFORK 2.2.x:auto-backport-of-pr-57333-on-2.2.x\n```\n\n5. Create a PR against branch 2.2.x, I would have named this PR:\n\n> \"Backport PR #57333 on branch 2.2.x (REGR: merge with 3rd party EA's can sometimes raise ValueError)\"\n\nAnd apply the correct labels and milestones.\n\nCongratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!\n\nRemember to remove the `Still Needs Manual Backport` label once the PR gets merged.\n\nIf these instructions are inaccurate, feel free to [suggest an improvement](https://github.com/MeeseeksBox/MeeseeksDev).\n " ]
2,128,044,724
57,332
CLN: Enforce deprecation of Series.agg using Series.apply
closed
2024-02-10T01:58:51
2024-02-10T12:41:16
2024-02-10T11:39:39
https://github.com/pandas-dev/pandas/pull/57332
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57332
https://github.com/pandas-dev/pandas/pull/57332
rhshadrach
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. Ref: #53325 cc @topper-123
[ "Clean", "Apply" ]
0
0
0
0
0
0
0
0
[ "thx @rhshadrach " ]
2,128,040,726
57,331
Backport PR #57322 on branch 2.2.x (REGR: Fix astype conversion of ea int to td/dt with missing values)
closed
2024-02-10T01:46:57
2024-02-10T11:25:24
2024-02-10T11:25:24
https://github.com/pandas-dev/pandas/pull/57331
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57331
https://github.com/pandas-dev/pandas/pull/57331
meeseeksmachine
0
Backport PR #57322: REGR: Fix astype conversion of ea int to td/dt with missing values
[ "Dtype Conversions", "NA - MaskedArrays" ]
0
0
0
0
0
0
0
0
[]
2,128,027,089
57,330
CLN: Enforce change in default value of observed
closed
2024-02-10T01:10:48
2024-02-10T12:41:24
2024-02-10T11:39:05
https://github.com/pandas-dev/pandas/pull/57330
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57330
https://github.com/pandas-dev/pandas/pull/57330
rhshadrach
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. Ref: #51811
[ "Groupby", "Categorical", "Clean" ]
0
0
0
0
0
0
0
0
[ "thx @rhshadrach " ]
2,128,025,113
57,329
REGR: CategoricalIndex.difference with null values
closed
2024-02-10T01:05:52
2024-02-10T11:38:09
2024-02-10T11:38:06
https://github.com/pandas-dev/pandas/pull/57329
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57329
https://github.com/pandas-dev/pandas/pull/57329
lukemanley
1
- [x] closes #57318 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [x] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [x] Added an entry in the latest `doc/source/whatsnew/v2.2.1.rst` file if fixing a bug or adding a new feature.
[ "Regression", "Categorical", "setops" ]
0
0
0
0
0
0
0
0
[ "thx" ]
2,127,990,136
57,328
Enforce silent downcasting deprecation
closed
2024-02-09T23:55:34
2024-02-28T18:01:00
2024-02-13T17:39:16
https://github.com/pandas-dev/pandas/pull/57328
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57328
https://github.com/pandas-dev/pandas/pull/57328
phofl
2
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl ", "https://github.com/pandas-dev/pandas/issues/57403" ]
2,127,945,510
57,327
CoW: Remove copy-keywords as far as possible
closed
2024-02-09T22:46:39
2024-02-10T11:25:46
2024-02-10T01:45:59
https://github.com/pandas-dev/pandas/pull/57327
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57327
https://github.com/pandas-dev/pandas/pull/57327
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. This is a preparation for deprecating copy and also cleaning up unused branches now
[ "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,127,911,211
57,326
Backport PR #57250 on branch 2.2.x (REGR/DOC: pd.concat should special case DatetimeIndex to sort even when sort=False)
closed
2024-02-09T22:07:08
2024-02-09T23:30:09
2024-02-09T23:30:08
https://github.com/pandas-dev/pandas/pull/57326
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57326
https://github.com/pandas-dev/pandas/pull/57326
meeseeksmachine
0
Backport PR #57250: REGR/DOC: pd.concat should special case DatetimeIndex to sort even when sort=False
[ "Docs", "Reshaping", "Regression" ]
0
0
0
0
0
0
0
0
[]
2,127,909,528
57,325
Backport PR #57121 on branch 2.2.x (REGR: Fix to_numpy for masked array with non-numeric dtype)
closed
2024-02-09T22:05:25
2024-02-09T23:29:56
2024-02-09T23:29:56
https://github.com/pandas-dev/pandas/pull/57325
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57325
https://github.com/pandas-dev/pandas/pull/57325
meeseeksmachine
0
Backport PR #57121: REGR: Fix to_numpy for masked array with non-numeric dtype
[ "NA - MaskedArrays" ]
0
0
0
0
0
0
0
0
[]
2,127,899,695
57,324
CoW: Remove remaining occurrences from CoW
closed
2024-02-09T21:54:50
2024-02-12T18:29:28
2024-02-12T18:27:38
https://github.com/pandas-dev/pandas/pull/57324
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57324
https://github.com/pandas-dev/pandas/pull/57324
phofl
1
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "Thanks @phofl " ]
2,127,884,675
57,323
REGR: Fix regression when grouping over a Series
closed
2024-02-09T21:40:47
2024-02-10T21:10:25
2024-02-10T21:10:22
https://github.com/pandas-dev/pandas/pull/57323
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57323
https://github.com/pandas-dev/pandas/pull/57323
phofl
0
- [ ] closes #57276 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Regression", "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[]
2,127,870,982
57,322
REGR: Fix astype conversion of ea int to td/dt with missing values
closed
2024-02-09T21:28:05
2024-02-10T11:25:20
2024-02-10T01:46:50
https://github.com/pandas-dev/pandas/pull/57322
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57322
https://github.com/pandas-dev/pandas/pull/57322
phofl
2
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. cc @lukemanley it should be covered by the other whatsnew
[ "Dtype Conversions", "NA - MaskedArrays" ]
0
0
0
0
0
0
0
0
[ "LGTM", "Thanks @phofl " ]
2,127,855,728
57,321
DOC: fix PR02 errors in docstring for pandas.Series.str.wrap
closed
2024-02-09T21:13:11
2024-02-13T16:58:52
2024-02-13T16:58:43
https://github.com/pandas-dev/pandas/pull/57321
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57321
https://github.com/pandas-dev/pandas/pull/57321
jordan-d-murphy
4
All PR02 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=PR02 pandas.Series.str.wrap - [x] xref https://github.com/pandas-dev/pandas/issues/57111 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "Code Style" ]
0
0
0
0
0
0
0
0
[ "I've updated the signature of wrap but now some of my tests are failing, I'll need to fix this before you take another look @mroeschke ", "@mroeschke ready for your review when you get a chance", "pre-commit.ci autofix\r\n\r\n", "Thanks @jordan-d-murphy " ]
2,127,841,046
57,320
BUG: `fill_value` does not work with binary operations between a Series and an Index object.
closed
2024-02-09T21:02:09
2024-02-11T02:55:31
2024-02-11T02:55:23
https://github.com/pandas-dev/pandas/issues/57320
true
null
null
sfc-gh-vbudati
2
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example On the latest version of Pandas, performing the following raises a ValueError. ```python import pandas as pd s = pd.Series([100, None, None]) rhs = pd.Index([25.4, 175, None]) s.add(rhs, fill_value=10) ``` ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/user/anaconda3/envs/latestpandas/lib/python3.12/site-packages/pandas/core/series.py", line 6286, in add return self._flex_method( ^^^^^^^^^^^^^^^^^^ File "/Users/user/anaconda3/envs/latestpandas/lib/python3.12/site-packages/pandas/core/series.py", line 6236, in _flex_method if isna(other): ^^^^^^^^^^^ ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ``` ### Issue Description - Arithmetic binary operations have an optional parameter `fill_value` to replace any NaN values with the given `fill_value`. - The ideal behavior is that given the lhs (Series `s`) and rhs (Index `rhs`), if only one of them is NaN, that is replaced by the fill_value. However, in pandas 2.2.0, it raises a value error instead. ### Expected Behavior The expected result is ``` 0 125.4 1 185.0 2 NaN dtype: float64 ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.12.1.final.0 python-bits : 64 OS : Darwin OS-release : 23.3.0 Version : Darwin Kernel Version 23.3.0: Wed Dec 20 21:31:00 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6020 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : None LOCALE : None.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 24.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None </details>
[ "Bug", "Numeric Operations" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report! [The documentation](https://pandas.pydata.org/docs/reference/api/pandas.Series.add.html) states this method only takes Series or scalar values. You can wrap your index in a Series:\r\n\r\n```\r\ns = pd.Series([100, None, None])\r\nrhs = pd.Index([25.4, 175, None])\r\nprint(s.add(pd.Series(rhs), fill_value=10))\r\n# 0 125.4\r\n# 1 185.0\r\n# 2 NaN\r\n# dtype: float6\r\n```", "It seems to me that allowing addition of an index confuses the role of index vs values. Closing." ]
2,127,684,879
57,319
CLN: Remove Series.view/ravel, fastpath
closed
2024-02-09T18:50:34
2024-02-09T20:52:45
2024-02-09T20:51:33
https://github.com/pandas-dev/pandas/pull/57319
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57319
https://github.com/pandas-dev/pandas/pull/57319
mroeschke
1
ref https://github.com/pandas-dev/pandas/pull/56053, https://github.com/pandas-dev/pandas/pull/56054, https://github.com/pandas-dev/pandas/pull/55466
[ "Clean", "Series" ]
0
0
0
0
0
0
0
0
[ "thx" ]
2,127,647,874
57,318
BUG: Pandas 2.2: `Index.difference` regression with categoricals
closed
2024-02-09T18:22:59
2024-02-10T11:38:07
2024-02-10T11:38:07
https://github.com/pandas-dev/pandas/issues/57318
true
null
null
galipremsagar
2
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python In [1]: import pandas as pd In [2]: pd.__version__ Out[2]: '2.2.0' In [3]: i = pd.Index(['a', 'b', 'c', None], dtype='category') In [4]: i Out[4]: CategoricalIndex(['a', 'b', 'c', nan], categories=['a', 'b', 'c'], ordered=False, dtype='category') In [5]: i.difference(['1']) Out[5]: CategoricalIndex(['a', 'b', 'c', nan], categories=['a', 'b', 'c'], ordered=False, dtype='category') In [6]: i.difference(['1', None]) --------------------------------------------------------------------------- KeyError Traceback (most recent call last) File /nvme/0/pgali/envs/cudfdev/lib/python3.10/site-packages/pandas/core/indexes/base.py:3802, in Index.get_loc(self, key) 3801 try: -> 3802 return self._engine.get_loc(casted_key) 3803 except KeyError as err: File index.pyx:153, in pandas._libs.index.IndexEngine.get_loc() File index.pyx:182, in pandas._libs.index.IndexEngine.get_loc() File pandas/_libs/hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item() File pandas/_libs/hashtable_class_helper.pxi:7089, in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: nan The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last) Cell In[6], line 1 ----> 1 i.difference(['1', None]) File /nvme/0/pgali/envs/cudfdev/lib/python3.10/site-packages/pandas/core/indexes/base.py:3661, in Index.difference(self, other, sort) 3658 return result.sort_values() 3659 return result -> 3661 result = self._difference(other, sort=sort) 3662 return self._wrap_difference_result(other, result) File /nvme/0/pgali/envs/cudfdev/lib/python3.10/site-packages/pandas/core/indexes/base.py:3667, in Index._difference(self, other, sort) 3664 def _difference(self, other, sort): 3665 # overridden by RangeIndex 3666 other = other.unique() -> 3667 the_diff = self[other.get_indexer_for(self) == -1] 3668 the_diff = the_diff if self.is_unique else the_diff.unique() 3669 the_diff = _maybe_try_sort(the_diff, sort) File /nvme/0/pgali/envs/cudfdev/lib/python3.10/site-packages/pandas/core/indexes/base.py:6181, in Index.get_indexer_for(self, target) 6163 """ 6164 Guaranteed return of an indexer even when non-unique. 6165 (...) 6178 array([0, 2]) 6179 """ 6180 if self._index_as_unique: -> 6181 return self.get_indexer(target) 6182 indexer, _ = self.get_indexer_non_unique(target) 6183 return indexer File /nvme/0/pgali/envs/cudfdev/lib/python3.10/site-packages/pandas/core/indexes/base.py:3923, in Index.get_indexer(self, target, method, limit, tolerance) 3917 indexer = algos.take_nd(categories_indexer, target.codes, fill_value=-1) 3919 if (not self._is_multi and self.hasnans) and target.hasnans: 3920 # Exclude MultiIndex because hasnans raises NotImplementedError 3921 # we should only get here if we are unique, so loc is an integer 3922 # GH#41934 -> 3923 loc = self.get_loc(np.nan) 3924 mask = target.isna() 3925 indexer[mask] = loc File /nvme/0/pgali/envs/cudfdev/lib/python3.10/site-packages/pandas/core/indexes/base.py:3809, in Index.get_loc(self, key) 3804 if isinstance(casted_key, slice) or ( 3805 isinstance(casted_key, abc.Iterable) 3806 and any(isinstance(x, slice) for x in casted_key) 3807 ): 3808 raise InvalidIndexError(key) -> 3809 raise KeyError(key) from err 3810 except TypeError: 3811 # If we have a listlike key, _check_indexing_error will raise 3812 # InvalidIndexError. Otherwise we fall through and re-raise 3813 # the TypeError. 3814 self._check_indexing_error(key) KeyError: nan ``` ### Issue Description There seems to be a `KeyError` in pandas-2.2, but in previous versions of pandas there was no error. ### Expected Behavior No error. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.10.13.final.0 python-bits : 64 OS : Linux OS-release : 5.15.0-91-generic Version : #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 24.0 Cython : 3.0.8 pytest : 7.4.4 hypothesis : 6.98.3 sphinx : 6.2.1 blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2024.2.0 gcsfs : None matplotlib : None numba : 0.59.0 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 14.0.1 pyreadstat : None python-calamine : None pyxlsb : None s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.25 tables : None tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None </details>
[ "Bug", "Categorical", "setops" ]
0
0
0
0
0
0
0
0
[ "cc: @mroeschke ", "This may have been caused by https://github.com/pandas-dev/pandas/pull/55108 cc @lukemanley " ]
2,127,625,183
57,317
BUG: 2.2.0 nunique aggregation with numeric categories produces different results for `s.groupby(s).agg(pd.Series.nunique)` and `s.groupby(s).nunique()`
closed
2024-02-09T18:06:43
2024-02-15T21:09:57
2024-02-15T21:09:52
https://github.com/pandas-dev/pandas/issues/57317
true
null
null
tamargrey
8
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd s = pd.Series(pd.Categorical([0, 1, 2, 0, 1], categories=[0, 1, 2], ordered=True)) via_agg = s.groupby(s).agg(pd.Series.nunique) direct = s.groupby(s).nunique() assert str(via_agg.dtype) == 'category' assert str(direct.dtype) == 'int64' # My use-case that is now broken - performing another aggregation now raises TypeError: category type does not support sum operations df = pd.DataFrame({'col1': via_agg, 'col2': ['a', 'b', 'c']}) df.groupby(['col2']).sum() ``` ### Issue Description `s.groupby(s).agg(pd.Series.nunique)` with numeric categories produces different results in pandas 2.2.0 than it did in earlier versions. Specifically, the resulting dtype is now `CategoricalDtype(categories=[0, 1, 2], ordered=True, categories_dtype=int64)` where it previously was just `int64`. Other things I've noticed - The other ways of doing this calculation, `s.groupby(s).nunique()` and `s.groupby(s).unique().apply(len)` still produce `int64` dtypes, which leads me to think that that is the correct dtype here. - There are some instances where `int64` dtype still gets used. If `s` is `pd.Series(pd.Categorical([1, 2, 2, 2, 2, 2], categories=[1, 2, 3], ordered=True))`, this problem does not occur. - If the categories aren't numeric, say `s` is `pd.Series(pd.Categorical(['a', 'b', 'c'], categories=["a", "b", "c"], ordered=True))` we still get the `int64` dtype, so this seems to only be a problem with numeric categories. I am using `.agg` since I want to make the call to `pd.Series.nunique` along with other aggregation functions at the same time, so I do not currently have a good workaround other than converting these categorical columns to be `int64`. The category dtype is problematic, as I am performing another groupby aggregation on the results, and this is resulting in `TypeError: category type does not support sum operations` errors on the categorical columns which were previously `int64`. ### Expected Behavior `s.groupby(s).agg(pd.Series.nunique)` should produce a series with the `int64` dtype that is equal to the other ways of performing this calculation. The following should run without problems: ```python import pandas as pd s = pd.Series(pd.Categorical([0, 1, 2, 0, 1], categories=[0, 1, 2], ordered=True)) via_agg = s.groupby(s).agg(pd.Series.nunique) direct = s.groupby(s).nunique() pd.testing.assert_series_equal(via_agg, direct) # My use-case should now work df = pd.DataFrame({'col1': via_agg, 'col2': ['a', 'b', 'c']}) df.groupby(['col2']).sum() ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.10.13.final.0 python-bits : 64 OS : Darwin OS-release : 21.6.0 Version : Darwin Kernel Version 21.6.0: Fri Sep 15 16:17:04 PDT 2023; root:xnu-8020.240.18.703.5~1/RELEASE_ARM64_T6000 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.0 numpy : 1.23.5 pytz : 2024.1 dateutil : 2.8.2 setuptools : 65.5.0 pip : 23.0.1 Cython : None pytest : 8.0.0 hypothesis : None sphinx : 5.1.1 blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.4.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2024.2.0 gcsfs : None matplotlib : 3.7.2 numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 12.0.1 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.12.0 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None </details>
[ "Bug", "Groupby", "Apply" ]
0
0
0
0
0
0
0
0
[ "I'm guessing this is more likely coming from of `s.groupby(s).agg` than `pd.Series.nunique`, because I can reproduce the same results by creating a wrapper function for `s.nunique()` and passing that into the `agg` method: \r\n\r\n```python\r\ns = pd.Series(pd.Categorical([0, 1, 2, 0, 1], categories=[0, 1, 2], ordered=True))\r\n\r\ndef wrapper(s):\r\n return s.nunique()\r\n\r\nvia_agg = s.groupby(s).agg(wrapper)\r\ndirect = s.groupby(s).nunique()\r\n\r\nassert str(via_agg.dtype) == 'category'\r\nassert str(direct.dtype) == 'int64'\r\n\r\n# My use-case that is now broken - performing another aggregation now raises TypeError: category type does not support sum operations\r\ndf = pd.DataFrame({'col1': via_agg, 'col2': ['a', 'b', 'c']})\r\ndf.groupby(['col2']).sum()\r\n\r\n```", "Thanks for the report. `groupby.agg` with a callable knows nothing about the operation you're performing, and so has to guess at what you want the results to be. After the operation, we check if the values can be stored in the original dtype and covert it back when that's possible. This seems to me to be a desired behavior in many, but not all, situations.\r\n\r\nAre you not able to use `.groupby(...).nunique()` or `.groupby(...).agg('nunique')`?", "@rhshadrach Using `nunique` does indeed let us avoid the error, but it's not ideal, as we expect that value to be a function that takes a series as input. In Featuretools, we determine which aggregations can apply to which columns in a DataFrame in one step and then apply them all at once via `.groupby(...).agg(`. This is also why `.groupby(...).nunique()` doesn't work for us. `'nunique'`, though not a function, can be passed into `.agg`, so we may be able to use it as a workaround for now. \r\n\r\nI think I agree that `agg` maintaining the original dtype if possible does make sense in many cases, as you say, but `nunique` is a good exception to that rule. We know it will always produce integers, and for data science purposes, the resulting column being potentially a `category` with integer `categories` is a fairly large semantic difference. Is the plan to come up with a fix for the behavior in this bug? Or is it not something that can be handled given `agg`'s lack of information about the operations it's calling? ", "> as we expect that value to be a function that takes a series as input\r\n\r\nWhy can't you expect a string or function?", "In Featuretools, we define [Primitives](https://featuretools.alteryx.com/en/stable/getting_started/primitives.html) as the basic operations that we may want to apply to columns in a feature matrix (which, in this case, are pandas DataFrames) to produce features. \r\n\r\nThe operations that primitives use to build these features are defined in their `get_function` method. The results of `get_function` can then be applied to data in two ways:\r\n1. Directly, by instantiating and then calling the primitive on an individual series. This eventually attempts to call the result of the `get_function` method, assuming it is a function that takes in a series. ([link](https://github.com/alteryx/featuretools/blob/main/featuretools/primitives/base/primitive_base.py#L61-L62)).\r\n2. Via Deep Feature Synthesis, by passing the primitive into `dfs`, where it will eventually be used on any relevant columns in your inputted DataFrame. Aggregation functions are passed in, en masse, to [s.groupby(...).agg(...)](https://github.com/alteryx/featuretools/blob/main/featuretools/computational_backends/feature_set_calculator.py#L824-L828). Simpler transform primitives call the result of the `get_function` method directly ([link](https://github.com/alteryx/featuretools/blob/main/featuretools/computational_backends/feature_set_calculator.py#L523-L529)).\r\n\r\nThe fact that returning strings from `get_function` happens to work for aggregation primitives in the second way above is more of an accident than anything else. But the second way is the more common use of primitives, so we do use strings when necessary, but it's not preferred. We don't currently have plans to add widespread support for strings being returned from `get_function`, so we try to not use strings when possible.", "Thanks @tamargrey - right before you call `.agg(...)`, why can't you just swap out the argument?\r\n\r\n```\r\nswaps = {pd.Series.nunique: \"nunique\"}\r\nto_agg = {column: [swaps.get(func, func) for func in funcs] for column, funcs in to_agg.items()}\r\n```\r\n\r\nRight now agg takes the callable as provided, uses it, and does some (perhaps not well-documented) post-processing. By trying to identify certain functions and resorting to different behavior, it makes the method more complicated for pandas to maintain and users to predict. For this reason I'm opposed.\r\n\r\nIf we were to move forward with detecting which callable a user passed and resorted to different behavior, for API consistency I think it would need to be done for every method supported across `Series`, `DataFrame`, `SeriesGroupBy`, `DataFrameGroupBy`, `Rolling`, `Resample`, and the window variants like `ExponentialMovingWindow`, `ExponentialMovingWindowGroupBy`, `Expanding`, etc. It would also need to be done for `agg`, `apply`, `transform` and `map`. The current behavior would need to be deprecated, and then change upon the next major release. This is no small effort.", "Got it, I think we have sufficient workarounds for now, so I am okay with not changing the behavior as long as using the string `'nunique'` keeps its current behavior!", "Thanks for getting back to us!" ]
2,127,540,235
57,316
BUG: ExtensionArray no longer can be merged with Pandas 2.2
closed
2024-02-09T17:10:38
2024-02-10T16:18:46
2024-02-10T16:18:46
https://github.com/pandas-dev/pandas/issues/57316
true
null
null
hoxbro
2
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd from datashader.datatypes import RaggedArray key = RaggedArray([[0, 1], [1, 2, 3, 4]], dtype='float64') df = pd.DataFrame({"key": key, "val": [1, 2]}) pd.merge(df, df, on='key') ``` ### Issue Description We have an extension array, and after upgrading to Pandas 2.2. Some of our tests are beginning to fail (`test_merge_on_extension_array`). This is related to changes made in https://github.com/pandas-dev/pandas/pull/56523. More specifically, these lines: https://github.com/pandas-dev/pandas/blob/1aeaf6b4706644a9076eccebf8aaf8036eabb80c/pandas/core/reshape/merge.py#L1751-L1755 This will raise the error below, with the example above <details> <summary> Traceback </summary> ``` python-traceback --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[1], line 7 4 key = RaggedArray([[0, 1], [1, 2, 3, 4]], dtype='float64') 5 df = pd.DataFrame({"key": key, "val": [1, 2]}) ----> 7 pd.merge(df, df, on='key') File ~/miniconda3/envs/holoviz/lib/python3.12/site-packages/pandas/core/reshape/merge.py:184, in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate) 169 else: 170 op = _MergeOperation( 171 left_df, 172 right_df, (...) 182 validate=validate, 183 ) --> 184 return op.get_result(copy=copy) File ~/miniconda3/envs/holoviz/lib/python3.12/site-packages/pandas/core/reshape/merge.py:886, in _MergeOperation.get_result(self, copy) 883 if self.indicator: 884 self.left, self.right = self._indicator_pre_merge(self.left, self.right) --> 886 join_index, left_indexer, right_indexer = self._get_join_info() 888 result = self._reindex_and_concat( 889 join_index, left_indexer, right_indexer, copy=copy 890 ) 891 result = result.__finalize__(self, method=self._merge_type) File ~/miniconda3/envs/holoviz/lib/python3.12/site-packages/pandas/core/reshape/merge.py:1151, in _MergeOperation._get_join_info(self) 1147 join_index, right_indexer, left_indexer = _left_join_on_index( 1148 right_ax, left_ax, self.right_join_keys, sort=self.sort 1149 ) 1150 else: -> 1151 (left_indexer, right_indexer) = self._get_join_indexers() 1153 if self.right_index: 1154 if len(self.left) > 0: File ~/miniconda3/envs/holoviz/lib/python3.12/site-packages/pandas/core/reshape/merge.py:1125, in _MergeOperation._get_join_indexers(self) 1123 # make mypy happy 1124 assert self.how != "asof" -> 1125 return get_join_indexers( 1126 self.left_join_keys, self.right_join_keys, sort=self.sort, how=self.how 1127 ) File ~/miniconda3/envs/holoviz/lib/python3.12/site-packages/pandas/core/reshape/merge.py:1753, in get_join_indexers(left_keys, right_keys, sort, how) 1749 left = Index(lkey) 1750 right = Index(rkey) 1752 if ( -> 1753 left.is_monotonic_increasing 1754 and right.is_monotonic_increasing 1755 and (left.is_unique or right.is_unique) 1756 ): 1757 _, lidx, ridx = left.join(right, how=how, return_indexers=True, sort=sort) 1758 else: File ~/miniconda3/envs/holoviz/lib/python3.12/site-packages/pandas/core/indexes/base.py:2251, in Index.is_monotonic_increasing(self) 2229 @property 2230 def is_monotonic_increasing(self) -> bool: 2231 """ 2232 Return a boolean if the values are equal or increasing. 2233 (...) 2249 False 2250 """ -> 2251 return self._engine.is_monotonic_increasing File index.pyx:262, in pandas._libs.index.IndexEngine.is_monotonic_increasing.__get__() File index.pyx:283, in pandas._libs.index.IndexEngine._do_monotonic_check() File index.pyx:297, in pandas._libs.index.IndexEngine._call_monotonic() File algos.pyx:853, in pandas._libs.algos.is_monotonic() ValueError: operands could not be broadcast together with shapes (4,) (2,) ``` </details> I can get things to run if I guard the check in a try/except like this: ``` python try: check = ( left.is_monotonic_increasing and right.is_monotonic_increasing and (left.is_unique or right.is_unique) ) except Exception: check = False if check: ... ``` ### Expected Behavior It will work like Pandas 2.1 and merge the two dataframes. ### Installed Versions <details> ``` yaml INSTALLED VERSIONS ------------------ commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.12.1.final.0 python-bits : 64 OS : Linux OS-release : 6.6.10-76060610-generic Version : #202401051437~1704728131~22.04~24d69e2 SMP PREEMPT_DYNAMIC Mon J machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 24.0 Cython : None pytest : 7.4.4 hypothesis : None sphinx : 5.3.0 blosc : None feather : None xlsxwriter : None lxml.etree : 5.1.0 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : None dataframe-api-compat : None fastparquet : 2023.10.1 fsspec : 2024.2.0 gcsfs : None matplotlib : 3.8.2 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.25 tables : None tabulate : 0.9.0 xarray : 2024.1.1 xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None ``` </details>
[ "Bug", "Reshaping", "Regression" ]
0
0
0
0
0
0
0
0
[ "cc @lukemanley ", "Thanks for the report. The underlying issue here is that `Index.is_monotonic_increasing` is raising in this case:\r\n\r\n```\r\nimport pandas as pd\r\nfrom datashader.datatypes import RaggedArray\r\n\r\nkey = RaggedArray([[0, 1], [1, 2, 3, 4]], dtype='float64')\r\n\r\npd.Index(key).is_monotonic_increasing # <- ValueError\r\n```\r\n\r\nI put a fix in #57333 to catch `ValueError` in addition to the other exception types already being caught. " ]
2,127,520,054
57,315
BUG: "ValueError: ndarray is not C-contiguous" when aggregating concatenated dataframe
closed
2024-02-09T16:56:58
2024-02-18T15:15:10
2024-02-18T15:15:10
https://github.com/pandas-dev/pandas/issues/57315
true
null
null
zephyrai-niq
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import numpy as np import pandas as pd for dtype in [np.int8, pd.Int8Dtype()]: df1 = pd.DataFrame( data={ "col1": pd.Series([1, 2, 3], index=["A", "B", "C"], dtype=dtype), }, index=pd.Index(["A", "B", "C"], dtype=pd.StringDtype()), ) df2 = pd.DataFrame( data={ "col2": pd.Series([4, 5, 6], index=["D", "E", "F"], dtype=dtype), }, index=pd.Index(["D", "E", "F"], dtype=pd.StringDtype()), ) df = pd.concat([df1, df2]) group = df.T.groupby(df.columns) max_df = group.max() print(max_df) print() ``` ### Issue Description I'm running into a `ValueError: ndarray is not C-contiguous` exception when attempting to aggregate a concatenated dataframe. Strangely though, the exception only seems to occur if the column dtypes are `pd.Int8Dtype()`, but not if they are `np.int8`. The example illustrates this issue. The first iteration of the loop runs properly, printing the following output: ``` A B C D E F col1 1.0 2.0 3.0 NaN NaN NaN col2 NaN NaN NaN 4.0 5.0 6.0 ``` However, the second iteration raises an unhandled exception on the `group.max()` call. Here is my (sanitized) callstack: ``` Traceback (most recent call last): File "/Users/redacted/git/myproject/foo.py", line 19, in <module> max_df = group.max() File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 3330, in max return self._agg_general( File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1906, in _agg_general result = self._cython_agg_general( File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1998, in _cython_agg_general new_mgr = data.grouped_reduce(array_func) File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 1473, in grouped_reduce applied = blk.apply(func) File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/internals/blocks.py", line 393, in apply result = func(self.values, **kwargs) File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/groupby/groupby.py", line 1973, in array_func result = self._grouper._cython_operation( File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 830, in _cython_operation return cy_op.cython_operation( File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 540, in cython_operation return values._groupby_op( File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/arrays/masked.py", line 1587, in _groupby_op res_values = op._cython_op_ndim_compat( File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 329, in _cython_op_ndim_compat res = self._call_cython_op( File "/Users/redacted/Library/Caches/pypoetry/virtualenvs/myproject-f89bfaSs-py3.9/lib/python3.9/site-packages/pandas/core/groupby/ops.py", line 418, in _call_cython_op func( File "groupby.pyx", line 1835, in pandas._libs.groupby.group_max File "<stringsource>", line 663, in View.MemoryView.memoryview_cwrapper File "<stringsource>", line 353, in View.MemoryView.memoryview.__cinit__ ValueError: ndarray is not C-contiguous ``` I discovered this issue when upgrading my code from _pandas_ `v1.5.3` to `v2.2.0`. With some trial and error though, I was able to determine that this issue was introduced with the `v2.1.0` release. (i.e. this issue does _not_ occur with `v2.0.3`) ### Expected Behavior I would expect both iterations of the for-loop in the example code to behave identically. However, only the first iteration succeeds; the second iteration raises an unhandled exception on the `group.max()` call. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.9.17.final.0 python-bits : 64 OS : Darwin OS-release : 23.3.0 Version : Darwin Kernel Version 23.3.0: Wed Dec 20 21:28:58 PST 2023; root:xnu-10002.81.5~7/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 23.0.1 Cython : None pytest : 7.4.4 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : None pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2023.12.2 gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : 12.0.1 pyreadstat : None python-calamine : None pyxlsb : None s3fs : 2023.12.2 scipy : 1.12.0 sqlalchemy : 2.0.25 tables : None tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None </details>
[ "Bug", "Reshaping", "Regression" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. Here is a simpler reproducer showing this isn't caused by `concat`, StringDtype columns, nor the presence of NA values:\r\n\r\n```\r\ndtype = \"Int64\"\r\ndf = pd.DataFrame(\r\n {\r\n \"col1\": pd.Series([1, 2, 3], dtype=dtype),\r\n \"col2\": pd.Series([1, 2, 3], dtype=dtype),\r\n },\r\n index=pd.Index([\"A\", \"B\", \"C\"]),\r\n)\r\nprint(df._mgr.blocks[0].values._data.flags['F_CONTIGUOUS'])\r\n# True\r\nprint(df.T._mgr.blocks[0].values._data.flags['F_CONTIGUOUS'])\r\n# False\r\n```\r\n\r\nDoing the same with non-EA dtypes, the transpose is F-contiguous (note: the groupby code takes a transpose, so F- and C-continuous flags get swapped).", "@rhshadrach Slight correction to your example. The first `print()` statement actually outputs `True`, not `False`:\r\n\r\n```python\r\nprint(df._mgr.blocks[0].values._data.flags[\"F_CONTIGUOUS\"])\r\n# True\r\n```", "Thanks! Fixed." ]
2,126,791,343
57,314
BUG: Fix near-minimum timestamp handling
closed
2024-02-09T09:45:39
2024-02-23T06:55:08
2024-02-22T23:53:20
https://github.com/pandas-dev/pandas/pull/57314
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57314
https://github.com/pandas-dev/pandas/pull/57314
robert-schmidtke
5
- [x] closes #57150 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [x] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. Previously, timestamps `1677-09-21 00:12:43.145224193` thru `1677-09-21 00:12:43.145224999` would raise an `OverflowError` due to the fact that `scaleMicrosecondsToNanoseconds` overflows as an intermediate step. After adding back the nanoseconds part, the timestamp would be valid again.
[ "Regression", "Timestamp" ]
0
0
0
0
0
0
0
0
[ "@WillAyd where would I add tests for this? If I'm not mistaken, then the `npy_datetimestruct_to_datetime` function is never tested directly. Should I use the reproducible example in the original issue or come up with a narrower test?", "> @WillAyd where would I add tests for this? If I'm not mistaken, then the `npy_datetimestruct_to_datetime` function is never tested directly. Should I use the reproducible example in the original issue or come up with a narrower test?\r\n\r\nI'll fix the failing Windows tests and found in the documentation some guidance on where and how to add the tests. Will mark ready for review once done.", "Heads up - I won't be able to review in detail until early next week", "I have started over with a failing test, see the results on https://github.com/pandas-dev/pandas/pull/57314/commits/b4c825da2f87131b379ee81119ccdc3ba8237fec.\r\n\r\nTo resolve, I went with a minimally invasive approach that just checks for negative extreme before scaling to microseconds, and then doing the calculation backwards from the minimum valid timestamp. I didn't find any constant defined for this (`NPY_MIN_INT64 + 1`), so instead of polluting the global namespace in `np_datetime.h`, I went with a local variable. This is probably compile-time optimized, so I expect no overhead by doing it this way.\r\n\r\nI only fixed the nanosecond case, because I was unable to devise tests for any other unit that would trigger this overflow, because:\r\n\r\n1. any datetime string is parsed by `dateutil`, which seems to hiccup when trying to parse dates like `-290308-12-21T19:59:05.224193` (the minimum valid microsecond timestamp, for example). So coarser resolutions than `ns` wouldn't work.\r\n2. for finer resolutions than `ns`, I was not sure how to execute the code paths, as the pandas timestamps seem to default to `ns` always, thus exiting at the branch that this PR fixes. Also, `np_datetime.pyx` says: `# AS, FS, PS versions exist but are not imported because they are not used.`", "Thanks @robert-schmidtke " ]
2,126,749,526
57,313
Float64 converted Int64 values are roundedoff due to None
closed
2024-02-09T09:18:39
2024-02-27T04:49:13
2024-02-09T22:00:22
https://github.com/pandas-dev/pandas/issues/57313
true
null
null
arunkumaralagesan
6
### Research - [X] I have asked my usage related question on [StackOverflow](https://stackoverflow.com). - [X] I have searched the [[pandas] tag](https://stackoverflow.com/questions/tagged/pandas) on StackOverflow for similar questions. ### Link to question on StackOverflow https://stackoverflow.com/questions/53327973/pandas-converting-null-int64-to-float64 ### Question about pandas Hi, I created a df with BigInt's and a single None value. Post conversion when i try to access the entries, the bigint numbers are overflowed and i could not get back the original value as it is. Even after typecasting, using `Decimal` package etc. Code: ``` import pandas as pd rounded_or_scientific_df = pd.DataFrame({ 'col1': [6760925268837314560, 6947311761343549440, 7103057685633208320, 6844033375485878447, 6844033375485878272, 6844033375485878550, 6944033375485878550, None], }) expected_df = pd.DataFrame({ 'col1': [6760925268837314560, 6947311761343549440, 7103057685633208320, 6844033375485878447, 6844033375485878272, 6844033375485878550, 6944033375485878550], }) The difference is the insertion of None. ``` Please refer the [google collab playground](https://colab.research.google.com/drive/1pRx-ypR31ua4fORiIVsaoM8iMYiE4s6b?usp=sharing). Thanks in advance! <img width="1202" alt="Screenshot 2024-02-09 at 2 27 24 PM" src="https://github.com/pandas-dev/pandas/assets/50190026/13ce4fde-2721-4b61-bce3-3e3a1571fd92">
[ "Missing-data", "Usage Question", "Duplicate Report", "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "The precision loss is when the array is constructed. `None` is interpreted as missing and using the default inference, `NaN` is used as the missing value indicator and a `float64` NumPy array is created to back the Series. Use Nullable arrays instead.\r\n\r\nI think the capitalization in the issue title is maybe confusing and that I have misunderstood the problem? `dtype: float64` is the default, `dtype: Float64` and `dtype: Int64` are Nullable types.\r\n\r\n```python\r\nrounded_or_scientific_df = pd.DataFrame({\r\n 'col1': [6760925268837314560, 6947311761343549440, 7103057685633208320, 6844033375485878447, 6844033375485878272, \r\n 6844033375485878550, 6944033375485878550, None],\r\n})\r\nrounded_or_scientific_df.col1\r\n# 0 6.760925e+18\r\n# 1 6.947312e+18\r\n# 2 7.103058e+18\r\n# 3 6.844033e+18\r\n# 4 6.844033e+18\r\n# 5 6.844033e+18\r\n# 6 6.944033e+18\r\n# 7 NaN\r\n# Name: col1, dtype: float64\r\nrounded_or_scientific_df = pd.DataFrame({\r\n 'col1': [6760925268837314560, 6947311761343549440, 7103057685633208320, 6844033375485878447, 6844033375485878272, \r\n 6844033375485878550, 6944033375485878550, None],\r\n}, dtype=\"Int64\")\r\nrounded_or_scientific_df.col1\r\n# 0 6760925268837314560\r\n# 1 6947311761343549440\r\n# 2 7103057685633208320\r\n# 3 6844033375485878447\r\n# 4 6844033375485878272\r\n# 5 6844033375485878550\r\n# 6 6944033375485878550\r\n# 7 <NA>\r\n# Name: col1, dtype: Int64\r\n```\r\n\r\n", "> The precision loss is when the array is constructed. `None` is interpreted as missing and using the default inference, `NaN` is used as the missing value indicator and a `float64` NumPy array is created to back the Series. Use Nullable arrays instead.\r\n> \r\n> I think the capitalization in the issue title is maybe confusing and that I have misunderstood the problem? `dtype: float64` is the default, `dtype: Float64` and `dtype: Int64` are Nullable types.\r\n> \r\n> ```python\r\n> rounded_or_scientific_df = pd.DataFrame({\r\n> 'col1': [6760925268837314560, 6947311761343549440, 7103057685633208320, 6844033375485878447, 6844033375485878272, \r\n> 6844033375485878550, 6944033375485878550, None],\r\n> })\r\n> rounded_or_scientific_df.col1\r\n> # 0 6.760925e+18\r\n> # 1 6.947312e+18\r\n> # 2 7.103058e+18\r\n> # 3 6.844033e+18\r\n> # 4 6.844033e+18\r\n> # 5 6.844033e+18\r\n> # 6 6.944033e+18\r\n> # 7 NaN\r\n> # Name: col1, dtype: float64\r\n> rounded_or_scientific_df = pd.DataFrame({\r\n> 'col1': [6760925268837314560, 6947311761343549440, 7103057685633208320, 6844033375485878447, 6844033375485878272, \r\n> 6844033375485878550, 6944033375485878550, None],\r\n> }, dtype=\"Int64\")\r\n> rounded_or_scientific_df.col1\r\n> # 0 6760925268837314560\r\n> # 1 6947311761343549440\r\n> # 2 7103057685633208320\r\n> # 3 6844033375485878447\r\n> # 4 6844033375485878272\r\n> # 5 6844033375485878550\r\n> # 6 6944033375485878550\r\n> # 7 <NA>\r\n> # Name: col1, dtype: Int64\r\n> ```\r\n\r\nHi Thanks for the insights. I understand passing force dtype works. But my bad that i did not provide example with all the conditions. In my use case, the df will contain many columns string, float, int, bigint. I just want to preserve the bigints as string as it is.\r\n\r\n```\r\nrounded_or_scientific_df = pd.DataFrame({\r\n 'col1': [6760925268837314560, 6947311761343549440, 6844033375485878272, \r\n 6844033375485878550, 6944033375485878550, None],\r\n 'col2': [\"test1\", \"test2\", \"test3\", \"test4\", \"test5\", \"test6\"],\r\n 'col3': [1.1, 2.2, 3.3, 4.4, 5.5, 6.6]\r\n})\r\n\r\nBut i want the \"col1\" values to be preserved either as int64 without rounding-off or scientific; or else better stringified.\r\nHow the schema would look like in this case?\r\nThanks again\r\n```", "> But i want the \"col1\" values to be preserved either as int64 without rounding-off or scientific; or else better stringified.\r\n\r\nyes, only a single dtype is allowed in the DataFrame constructor.\r\n\r\npass a Series or array instead for the columns that you want to control the dtype for and the others will still use the default inference.\r\n\r\n```python\r\nrounded_or_scientific_df = pd.DataFrame({\r\n 'col1': pd.array([6760925268837314560, 6947311761343549440, 6844033375485878272, \r\n 6844033375485878550, 6944033375485878550, None], dtype=str),\r\n 'col2': [\"test1\", \"test2\", \"test3\", \"test4\", \"test5\", \"test6\"],\r\n 'col3': [1.1, 2.2, 3.3, 4.4, 5.5, 6.6]\r\n})\r\nprint(rounded_or_scientific_df)\r\n# col1 col2 col3\r\n# 0 6760925268837314560 test1 1.1\r\n# 1 6947311761343549440 test2 2.2\r\n# 2 6844033375485878272 test3 3.3\r\n# 3 6844033375485878550 test4 4.4\r\n# 4 6944033375485878550 test5 5.5\r\n# 5 None test6 6.6\r\nrounded_or_scientific_df.dtypes\r\n# col1 object\r\n# col2 object\r\n# col3 float64\r\n# dtype: object\r\n```\r\n", "Looks to me like @simonjayhawkins's last code sample satisfies the request here. Closing for now - @arunkumaralagesan if you think there is still an issue in pandas comment here as we can reopen.", "> Closing for now - @arunkumaralagesan if you think there is still an issue in pandas comment here as we can reopen.\r\n\r\nor in #56678 as other than the performance discussion (for which I don't see evidence to back up the claim) this is moreless a duplicate of the start of that discussion.", "> > But i want the \"col1\" values to be preserved either as int64 without rounding-off or scientific; or else better stringified.\r\n> \r\n> yes, only a single dtype is allowed in the DataFrame constructor.\r\n> \r\n> pass a Series or array instead for the columns that you want to control the dtype for and the others will still use the default inference.\r\n> \r\n> ```python\r\n> rounded_or_scientific_df = pd.DataFrame({\r\n> 'col1': pd.array([6760925268837314560, 6947311761343549440, 6844033375485878272, \r\n> 6844033375485878550, 6944033375485878550, None], dtype=str),\r\n> 'col2': [\"test1\", \"test2\", \"test3\", \"test4\", \"test5\", \"test6\"],\r\n> 'col3': [1.1, 2.2, 3.3, 4.4, 5.5, 6.6]\r\n> })\r\n> print(rounded_or_scientific_df)\r\n> # col1 col2 col3\r\n> # 0 6760925268837314560 test1 1.1\r\n> # 1 6947311761343549440 test2 2.2\r\n> # 2 6844033375485878272 test3 3.3\r\n> # 3 6844033375485878550 test4 4.4\r\n> # 4 6944033375485878550 test5 5.5\r\n> # 5 None test6 6.6\r\n> rounded_or_scientific_df.dtypes\r\n> # col1 object\r\n> # col2 object\r\n> # col3 float64\r\n> # dtype: object\r\n> ```\r\n\r\nThanks for the suggestion, adding the bigInt cols with explicit datatype as `Int64` solves the use case. " ]
2,126,730,321
57,312
BUG: `sort_values` should have consistent behavior irrespective of the number of sort columns
open
2024-02-09T09:05:03
2024-02-12T22:20:54
null
https://github.com/pandas-dev/pandas/issues/57312
true
null
null
arpit-goel
5
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd import datetime df = pd.DataFrame([["", 1], [datetime.date.today(), 2]], columns=['a', 'b']) # column a contains mixed data df.sort_values(['a']) # raises error df.sort_values(['a', 'b']) # no error df.sort_values(['a', 'a']) # no error ``` ### Issue Description When using `sort_values` on a data frame where at least one column contains mixed data, it should handle it gracefully or raise appropriate errors. It raises an error if a mixed-type column is used for sorting and succeeds if multiple columns are used, where one of them is a mixed-type column. ### Expected Behavior The behvior should be consistent irrespective of the number of columns being used for sorting. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : 0f437949513225922d851e9581723d82120684a6 python : 3.9.16.final.0 python-bits : 64 OS : Darwin OS-release : 22.5.0 Version : Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.0.3 numpy : 1.24.3 pytz : 2022.1 dateutil : 2.8.2 setuptools : 65.5.1 pip : 22.0.4 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : 3.0.3 lxml.etree : 4.9.1 html5lib : None pymysql : None psycopg2 : 2.9.3 jinja2 : 3.0.1 IPython : 8.10.0 pandas_datareader: None bs4 : 4.11.1 bottleneck : None brotli : None fastparquet : None fsspec : 2022.5.0 gcsfs : None matplotlib : 3.7.0 numba : None numexpr : None odfpy : None openpyxl : 3.0.9 pandas_gbq : None pyarrow : 14.0.1 pyreadstat : None pyxlsb : None s3fs : None scipy : None snappy : None sqlalchemy : None tables : None tabulate : 0.8.9 xarray : None xlrd : None zstandard : None tzdata : 2022.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Sorting" ]
0
0
0
0
0
0
0
0
[ "take", "Thanks for the report; looks like we take different paths depending on whether there is a single or multiple columns to sort by. I'd guess this was done for performance reasons. Further investigations and PRs to fix are welcome!", "@rhshadrach Theres a few ways to patch this up but I'm concerned about some things. \r\n\r\nMerging the 2 conditionals within the core dataframe class' sort_values method\r\n\r\nhttps://github.com/pandas-dev/pandas/blob/f538741432edf55c6b9fb5d0d496d2dd1d7c2457/pandas/core/frame.py#L7155-L7186\r\n\r\nto \r\n\r\n```\r\nif len(by):\r\n keys = [self._get_label_or_level_values(x, axis=axis) for x in by]\r\n\r\n # need to rewrap columns in Series to apply key function\r\n if key is not None:\r\n # error: List comprehension has incompatible type List[Series];\r\n # expected List[ndarray]\r\n keys = [\r\n Series(k, name=name) # type: ignore[misc]\r\n for (k, name) in zip(keys, by)\r\n ]\r\n\r\n indexer = lexsort_indexer(\r\n keys, orders=ascending, na_position=na_position, key=key\r\n )\r\n```\r\n\r\nensures consistency by sorting using np.lexsort for all cases. \r\n\r\nhttps://github.com/pandas-dev/pandas/blob/f538741432edf55c6b9fb5d0d496d2dd1d7c2457/pandas/core/frame.py#L7155-L7191\r\n\r\nThat being said, performance will suffer for single column case due to extra overhead of np.lexsort compared to current implementation using the more simple argsort.\r\n\r\nAnother approach is to modify the behaviour of the nargsort function in the sorting module to handle this specific case. In particular, changing \r\n\r\nhttps://github.com/pandas-dev/pandas/blob/f538741432edf55c6b9fb5d0d496d2dd1d7c2457/pandas/core/sorting.py#L369-L450\r\n\r\nto\r\n\r\n```\r\n try:\r\n indexer = non_nan_idx[non_nans.argsort(kind=kind)]\r\n except (TypeError, AttributeError):\r\n # Convert datetime objects to ordinal representations\r\n non_nans_ordinals = []\r\n for d in non_nans:\r\n if isinstance(d, datetime.date):\r\n non_nans_ordinals.append(d.toordinal())\r\n else:\r\n # Handle non-date values gracefully\r\n non_nans_ordinals.append(d)\r\n\r\n indexer = non_nan_idx[np.argsort(non_nans_ordinals, kind=kind)]\r\n```\r\n\r\nkeeps the n_columns == 1 and > 1 situation have consistent sorting for the case where a , but introduces inconsistency for other cases. For example, if you add an additional row of all with every column as value 3 to the dataframe, the n_columns > 1 case fails while the n_columns == 1 case passes.\r\n\r\n```\r\nimport pandas as pd\r\nimport datetime\r\ndf = pd.DataFrame([[\"\", 1], [datetime.date.today(), 2], [3, 3]], columns=['a', 'b']) # column a contains mixed data\r\ndf.sort_values(['a']) # fixes this error\r\ndf.sort_values(['a', 'b']) # new error\r\ndf.sort_values(['a', 'a']) # new error\r\n```\r\n\r\nwhere the new error is \r\n\r\n> TypeError: 'values' is not ordered, please explicitly specify the categories order by passing in a categories argument.\r\n\r\nI guess I'm unsure whether there is any benefit to ensure consistency if performance will take a hit... second solution is beneficial but only for mixed type columns involving datetime objects. I'm also thinking it might actually be better to error out in case there are inconsistencies in the format of entries in a column so that its caught and relayed to the user. anyone have any thoughts?", "@remiBoudreau My 2 cents would be on ensuring consistency, whether that's raising errors or successful sorting. Of course, performance is important but not as important as accuracy and correctness. Let's try and side ourselves with whether we want to allow mixed-type columns or not and then the decision will follow to either raise errors or fix sorting.", "@remiBoudreau - I think we should maintain the fastpath for a single `by` - this is a very common case. That leaves either improving this path to handle this case, or having it raise in both cases. If we are to improve the fastpath to handle this case, it shouldn't be by using `try...except...`. That can hurt performance, hide bugs, and make things harder to debug.\r\n\r\nIf we want to make it so both paths raise here, we'd need to deprecate the current behavior for multiple `by` values. For this, a first step is in deciding what we want and don't want to support. For example, I know groupby has specific logic for handling sorting with integers, strings, and NA values mixed in." ]
2,126,380,286
57,311
Fixing multi method for to_sql for non-oracle databases
closed
2024-02-09T02:44:08
2024-02-17T01:10:06
2024-02-17T01:09:58
https://github.com/pandas-dev/pandas/pull/57311
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57311
https://github.com/pandas-dev/pandas/pull/57311
kassett
6
- [ ] closes #57310 - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/v2.2.1.rst` file if fixing a bug or adding a new feature.
[ "Regression", "IO SQL" ]
0
0
0
0
0
0
0
0
[ "Totally fair not to accept dialect specific changes, but with the previous commit, ALL queries using the method=\"multi\" argument resolve to insertion via single row. Is it worth breaking this functionality just for the sake of the Oracle connector?", "I think it's reasonable to revert https://github.com/pandas-dev/pandas/pull/51648 that broke this for all `method=\"multi\" ` queries. Would you be interested in making a PR to do that?", "Yes, I definitely can make that PR, should I keep it in this PR and just change it or make a new one?\r\nAlso, is it worth making a warning at least for Oracle?", "> Yes, I definitely can make that PR, should I keep it in this PR and just change it or make a new one?\r\n\r\nSure you can revert the code change in this PR. It would be good to add a unit test as well so it doesn't break again (`test_sql.py`)\r\n\r\n> Also, is it worth making a warning at least for Oracle?\r\n\r\nYeah in the docstring of `to_sql` that would be great", "Looking good but please run the pre-commit checks to fix style issues: https://pandas.pydata.org/docs/dev/development/contributing_codebase.html#pre-commit", "Thanks @kassett " ]
2,126,378,957
57,310
BUG: method="multi" is not working with DataFrame.to_sql
closed
2024-02-09T02:41:57
2024-02-17T01:09:59
2024-02-17T01:09:59
https://github.com/pandas-dev/pandas/issues/57310
true
null
null
kassett
0
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python df.to_sql(df, table, method="mutli") ``` ### Issue Description In version 2.2.0, support for writing to sql using the "multi" method. This was removed because Oracle does not support multi statements. ### Expected Behavior Prepared statements using multiple lines should write given that the chunksize is more than 1. ### Installed Versions <details> /Users/schai/repos/sagav3/venv/lib/python3.9/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.") INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.9.18.final.0 python-bits : 64 OS : Darwin OS-release : 22.6.0 Version : Darwin Kernel Version 22.6.0: Wed Jul 5 22:17:35 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8112 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : None LOCALE : None.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 68.2.2 pip : 23.3.1 Cython : None pytest : 7.4.4 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.18.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2024.2.0 gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : 2024.2.0 scipy : None sqlalchemy : 2.0.25 tables : None tabulate : None xarray : 2024.1.1 xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None </details>
[ "Bug", "Regression", "IO SQL" ]
0
0
0
0
0
0
0
0
[]
2,126,271,772
57,309
DOC: fix reference to api.typing.NaTType (from api.types.NaTType)
closed
2024-02-09T00:21:41
2024-02-11T10:44:17
2024-02-09T21:03:03
https://github.com/pandas-dev/pandas/pull/57309
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57309
https://github.com/pandas-dev/pandas/pull/57309
choucavalier
1
Effectively, the `NaTType` definition lives under `api.typing` and not `api.types`
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "thx @tgy" ]
2,126,226,277
57,308
CLN: Remove .bool(), __init__, __float__ from DataFrame/Series
closed
2024-02-08T23:24:05
2024-02-09T21:31:06
2024-02-09T21:13:48
https://github.com/pandas-dev/pandas/pull/57308
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57308
https://github.com/pandas-dev/pandas/pull/57308
mroeschke
2
xref https://github.com/pandas-dev/pandas/pull/51756, https://github.com/pandas-dev/pandas/pull/51131
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "needs a rebase but feel free to merge afterwards", "thx @mroeschke " ]
2,126,152,879
57,307
CLN: Remove literal string/bytes support in IO readers
closed
2024-02-08T22:11:55
2024-02-12T17:02:28
2024-02-10T11:42:20
https://github.com/pandas-dev/pandas/pull/57307
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57307
https://github.com/pandas-dev/pandas/pull/57307
mroeschke
1
xref https://github.com/pandas-dev/pandas/issues/53767
[ "IO Data", "Clean" ]
0
0
0
0
0
0
0
0
[ "thx @mroeschke " ]
2,125,931,490
57,306
TST: adds a test to check signedness preservation after sum
closed
2024-02-08T19:34:21
2024-02-08T23:39:29
2024-02-08T23:26:32
https://github.com/pandas-dev/pandas/pull/57306
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57306
https://github.com/pandas-dev/pandas/pull/57306
banorton
2
- [x] closes #37491 - [x] Tests added and passed - [x] All code checks passed Adds a test to make sure the result of sum does not alter the signedness of the input.
[ "Testing" ]
0
0
0
0
0
0
0
0
[ "I removed the unnecessary test and added the issue number :)", "Thanks @banorton " ]
2,125,801,251
57,305
Equivalent to df[:n] for non-negative values too
closed
2024-02-08T18:14:06
2024-02-20T21:33:11
2024-02-20T21:33:11
https://github.com/pandas-dev/pandas/issues/57305
true
null
null
snoyes
4
The documentation for pandas.DataFrame.head mentions that negative values of n are equivalent to df[:n]. This is true for all values of n. https://github.com/pandas-dev/pandas/blob/2110b742039c2ed0b1089015e2c39b6ef905dd7b/pandas/core/generic.py#L5617-L5618
[ "Docs", "Filters" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. I believe the intention here is to specifically highlight the behavior for negative values, which users might not consider, rather than to suggest this isn't the behavior for positive values.\r\n\r\nDo you find this confusing?", "It made me pause to wonder why it was only mentioned in the \"negative values\" section, worried that implies it does not behave that way for positive values and 0. I think the `df[:n]` bit should appear in a separate paragraph, so it's clearly true for all `n`.", "Hi @snoyes and @rhshadrach, I think the examples are quite self-explanatory, what about changing the first part to something like this: \r\n\r\nThis function exhibits the same behavior as `df[:n]`, returning the first `n` rows based on position. It is useful for quickly testing if your object has the right type of data in it.\r\n\r\nWhen `n` is positive, it returns the first `n` rows. For `n` equal to 0, it returns an empty object. For negative values of `n`, it returns all rows except the last `|n|` rows, mirroring the behavior of `df[:n]`.\r\n\r\nIf n is larger...\r\n ", "Hi @rhshadrach, I've created this morning a PR to improve the definition. However, I see there are some unrelated issues that are preventing the branch to pass the checks. Is there anything I can do? " ]
2,125,777,538
57,304
DOC: fix PR02 errors in docstring for pandas.core.groupby.DataFrameGroupBy.hist
closed
2024-02-08T17:59:41
2024-02-09T21:06:16
2024-02-09T20:52:25
https://github.com/pandas-dev/pandas/pull/57304
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57304
https://github.com/pandas-dev/pandas/pull/57304
jordan-d-murphy
2
All PR02 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=PR02 pandas.core.groupby.DataFrameGroupBy.hist - [x] xref https://github.com/pandas-dev/pandas/issues/57111 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "@mroeschke can you review my updated example for df.groupby().hist() when you get a chance?", "Thanks @jordan-d-murphy " ]
2,124,839,878
57,303
ENH: allows word / PPT / outlook formatting as output of to_clipboard
closed
2024-02-08T10:38:57
2024-03-18T01:57:07
2024-03-18T01:57:07
https://github.com/pandas-dev/pandas/issues/57303
true
null
null
lcrmorin
3
### Feature Type - [X] Adding new functionality to pandas - [ ] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description The function to_clipboard allow to copy a dataframe, then paste it. It has an option to format the data such as it is pastable directly into Excel. However it doesn't allow to paste the data into MS Word / Powerpoint / Outlook. Also - it might be a different issue - but it would be very nice to be able to copy style, as currently to_clipboard throws an error on a styler object. Best, Lucas ### Feature Description - allows to clipboard to works on styler objects - allows and option in to_clipboard to copy_paste to MS word / outlook / ppt ### Alternative Solutions current solution is to use pyperclip then copy paste into excel then into MS word / outlook / ppt ### Additional Context _No response_
[ "Enhancement", "IO Data", "Needs Discussion", "Styler", "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "Thanks for the request. Is there a suggested implementation? Here is the implementation for `excel=True`\r\n\r\n```\r\nif sep is None:\r\n sep = \"\\t\"\r\nbuf = StringIO()\r\n\r\n# clipboard_set (pyperclip) expects unicode\r\nobj.to_csv(buf, sep=sep, encoding=\"utf-8\", **kwargs)\r\ntext = buf.getvalue()\r\n\r\nclipboard_set(text)\r\n```\r\n\r\nIt seems to me an implementation for Word, PowerPoint, Outlook, and other applications would be much more effort and outside the scope of pandas.", "I am trying to understand what would be needed. I am asking here and there and will propose something when I figure out what would word need. ", "I don't think that we want to take on the burden of maintaining compatibility with these formats, this would need a 3rd party package that we could dispatch to" ]
2,124,321,199
57,302
DEPR: Enforce deprecation of previous implementation of DataFrame.stack
closed
2024-02-08T04:09:49
2024-02-14T03:02:06
2024-02-14T02:14:57
https://github.com/pandas-dev/pandas/pull/57302
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57302
https://github.com/pandas-dev/pandas/pull/57302
rhshadrach
7
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. Ref: https://github.com/pandas-dev/pandas/issues/53515 We need to keep the `future_stack` argument in 3.0, but have two choices: still allow users to specify `future_stack=False` (while always seeing the warning message) or remove `future_stack=False` entirely now. In either case, we'd introduce a deprecation of the `future_stack` argument (regardless of how it's being specified) as part of 3.x (I plan on 3.1). I went with the former option of still allowing `future_stack=False` - it seemed more gradual.
[ "Reshaping", "Clean" ]
0
0
0
0
0
0
0
0
[ "> We need to keep the `future_stack` argument in 3.0\r\n\r\nthat's unfortunate.", "Also were you thinking of deprecating `dropna` and `sort` in this PR as well?", "> Also were you thinking of deprecating `dropna` and `sort` in this PR as well?\r\n\r\nCurrently if you use `future_stack=True` we raise when dropna or sort are specified. So I don't think any action needs to be taken here.", "OK but in a follow up they will be deprecated then? I see from the 2.1 whatsnew\r\n\r\n> As such, the arguments dropna and sort are not utilized and must remain unspecified when using future_stack=True. These arguments will be removed in the next major release.", "I don't think there is a need to deprecate them - they must remain unspecified and so removing them is backwards compatible. In other words, if you run pandas 2.x (or 3.x) without any warnings, then your code will be fine in 4.0.", "> So in 4.0 we can just remove `sort` and `dropna` from the signature of `stack`?\r\n\r\nCorrect.", "Thanks @rhshadrach " ]
2,124,144,972
57,301
BUG: AssertionError calling df.shift(axis=1) on empty DataFrame
closed
2024-02-08T00:26:34
2024-02-17T21:58:58
2024-02-17T21:58:58
https://github.com/pandas-dev/pandas/issues/57301
true
null
null
sfc-gh-joshi
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd pd.DataFrame().shift(axis=1) ``` ### Issue Description The above code raises an AssertionError: ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/joshi/miniconda3/envs/pandas-latest/lib/python3.11/site-packages/pandas/core/frame.py", line 5799, in shift return super().shift( ^^^^^^^^^^^^^^ File "/Users/joshi/miniconda3/envs/pandas-latest/lib/python3.11/site-packages/pandas/core/generic.py", line 10706, in shift assert axis == 0 # axis == 1 cases handled in DataFrame.shift ^^^^^^^^^ AssertionError ``` ### Expected Behavior Shifting an empty dataframe should return an empty dataframe, regardless of axis (this behavior apparently worked in pandas 1.5.3). ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : 7fe86b67d3782d0c35b9284900e4aa9dd827718a python : 3.11.7.final.0 python-bits : 64 OS : Darwin OS-release : 23.3.0 Version : Darwin Kernel Version 23.3.0: Wed Dec 20 21:31:00 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6020 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 3.0.0.dev0+263.g7fe86b67d3 numpy : 2.0.0.dev0+git20240203.5c34c87 pytz : 2024.1 dateutil : 2.8.2 setuptools : 68.2.2 pip : 23.3.1 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None </details>
[ "Bug", "Regression", "Algos" ]
0
0
0
0
0
0
0
0
[ "Thanks for finding and reporting this issue. \r\nIs anyone looking into this issue or can I investigate this issue..?", "Go for it.", "Closed by #57340" ]
2,123,972,101
57,300
CLN: remove from PeriodIndex.asfreq unnecessary raising ValueError for invalid period freq
closed
2024-02-07T22:00:03
2024-02-08T09:02:55
2024-02-08T09:02:55
https://github.com/pandas-dev/pandas/pull/57300
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57300
https://github.com/pandas-dev/pandas/pull/57300
natmokval
1
xref #56945 removed from `PeriodIndex.asfreq` unnecessary raising ValueError for invalid period freq. Now we raise this ValueError for invalid period freq in `to_offset`.
[ "Frequency", "Clean" ]
0
0
0
0
0
0
0
0
[ "@MarcoGorelli, could you please take a look at this PR?" ]
2,123,806,033
57,299
ENH: Series.range() and DF.range() methods
closed
2024-02-07T20:20:24
2024-02-07T20:32:32
2024-02-07T20:32:32
https://github.com/pandas-dev/pandas/issues/57299
true
null
null
DarthKitten2130
1
### Feature Type - [X] Adding new functionality to pandas - [ ] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description I was wondering why pandas never had a range function in its statistics methods. Of course you can use `df.max() - df.min()` or `Series.max() - Series.min()` to achieve the same effect, but for readability sake I think it would be a nice addition to the API. ### Feature Description Adding a new method to both Series and DataFrame as shown in this example: ``` import pandas as pd ser1 = pd.Series([1,2,3,4,5]) df1 = pd.DataFrame({ 'x': [1,2,3,4,5], 'y': [10,20,30,40,50] }) print(ser1.range()) print(df1.range()) ``` Output: ``` 4 x 4 y 40 ``` ### Alternative Solutions You can always use `df.max() - df.min()` or `Series.max() - Series.min()` to achieve the same effect, however it's not that readable ### Additional Context _No response_
[ "Enhancement", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "Thanks for the request, but we've had similar requests in the past which were rejected since `max - min` is sufficient and not worth adding a separate API for this. I would recommend adding this method locally to your `pandas.DataFrame` if needed so closing" ]
2,123,804,281
57,298
ENH: `bool` upcast to `Int64`
open
2024-02-07T20:19:15
2024-02-15T04:20:04
null
https://github.com/pandas-dev/pandas/issues/57298
true
null
null
VladimirFokow
1
### Feature Type - [ ] Adding new functionality to pandas - [X] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description I wish I could upcast `bool` to `Int64` ### Feature Description I have data which can be either `bool` or `NaN`. So a simple `int(val)` wouldn't work (due to NaNs producing an error). I don't want a boolean output array, I want `Int64`. Is there a reason not to allow casting of `bools` to `Int64`? ```py # Toy example import pandas as pd data = [True, False, pd.NA] out = pd.Series(dtype='Int64', index=np.arange(5)) # Desired: for val in data: out[0] = val # TypeError: Invalid value 'True' for dtype Int64 ``` ### Alternative Solutions ```py # Current workaround: for val in data: out[0] = pd.Series(val, dtype='Int64')[0] ``` ### Additional Context - Would the integration with Arrow be a good opportunity to implement these? - because [here](https://pandas.pydata.org/docs/dev/user_guide/basics.html#astype) it says: > Upcasting is always according to the NumPy rules. If two different dtypes are involved in an operation, then the more general one will be used as the result of the operation. .. maybe now it's not going to be "always according to the NumPy rules" but also to some Arrow rules? - Are there any other not-implemented upcasting rules which should be? However, this proves that such upcasting already works, so I'm puzzled why my example above doesn't: ```py s = pd.Series(data) s.astype('Int64') ``` is the tag `BUG:` more appropriate here?
[ "Enhancement", "Needs Discussion", "NA - MaskedArrays", "PDEP6-related" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. Perhaps a better alternative would be `out[0] = val if pd.isna(val) else int(val)`. This avoids (somewhat expensive) Series construction.\r\n\r\ncc @MarcoGorelli " ]
2,123,744,639
57,297
BUG: sort_index(1, ignore_index=True, ascending=False)
closed
2024-02-07T19:40:44
2024-02-09T20:59:58
2024-02-09T20:59:11
https://github.com/pandas-dev/pandas/pull/57297
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57297
https://github.com/pandas-dev/pandas/pull/57297
mroeschke
1
- [ ] closes #57293 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Bug" ]
0
0
0
0
0
0
0
0
[ "thx" ]
2,123,677,876
57,296
CLN: Remove pandas.value_counts, Index.format, is_interval, is_period
closed
2024-02-07T19:00:04
2024-02-09T22:08:59
2024-02-09T22:07:53
https://github.com/pandas-dev/pandas/pull/57296
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57296
https://github.com/pandas-dev/pandas/pull/57296
mroeschke
1
https://github.com/pandas-dev/pandas/pull/56038 https://github.com/pandas-dev/pandas/pull/55439 https://github.com/pandas-dev/pandas/pull/53493
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "thx @mroeschke " ]
2,123,540,416
57,295
BUG: Updated _pprint_seq to use enumerate instead of next
closed
2024-02-07T17:35:52
2024-02-09T21:04:31
2024-02-09T21:04:26
https://github.com/pandas-dev/pandas/pull/57295
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57295
https://github.com/pandas-dev/pandas/pull/57295
cliffckerr
1
This PR closes an edge-case [bug](https://github.com/pandas-dev/pandas/issues/16098) that has been around for almost 7 years. To print a DataFrame, the function `_pprint_seq()` constructs a string representation of an iterable object (called `seq`) by creating an iterator over it, and truncating it if `len(seq) > max_seq_items`. However, a pandas `DataFrame` is an example of an object where `len(seq)` is _not_ a valid way of checking the length of the iterator. Specifically, `len(df)` returns the number of rows, while `iter(df)` iterates over the columns. When trying to print a DataFrame with more rows than columns, this raises a `StopIterator` exception. This PR fixes this bug by explicitly iterating over the object, rather than assuming that `len(seq)` is equal to the number of items in the object. The new test `test_nested_dataframe()` raises an exception on `main`, but passes on this branch. - [x] closes #16098 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests). - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) (no new arguments/methods/functions). - [x] Added an entry in `doc/source/whatsnew/v3.0.0.rst`.
[ "Bug", "Output-Formatting" ]
0
0
0
0
0
0
0
0
[ "thx @cliffckerr " ]
2,123,467,186
57,294
Backport PR #57233 on branch 2.2.x (REGR: Fix to_numpy conversion for arrow ea with float dtype given)
closed
2024-02-07T16:52:36
2024-02-07T18:02:07
2024-02-07T18:02:06
https://github.com/pandas-dev/pandas/pull/57294
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57294
https://github.com/pandas-dev/pandas/pull/57294
meeseeksmachine
0
Backport PR #57233: REGR: Fix to_numpy conversion for arrow ea with float dtype given
[ "Arrow" ]
0
0
0
0
0
0
0
0
[]
2,123,194,677
57,293
BUG: `sort_index` not preserving `index` when `ascending=False`
closed
2024-02-07T14:43:43
2024-02-09T20:59:12
2024-02-09T20:59:12
https://github.com/pandas-dev/pandas/issues/57293
true
null
null
galipremsagar
2
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python In [1]: import pandas as pd In [2]: import numpy as np In [3]: pdf = pd.DataFrame( ...: { ...: "b": [1.0, 3.0, np.nan], ...: "a": [1, 4, 3], ...: 1: ["a", "b", "c"], ...: "e": [3, 1, 4], ...: "d": [1, 2, 8], ...: } ...: ) In [4]: pdf = pdf.set_index(["b", "a", 1]) In [5]: pdf.sort_index(axis='columns') Out[5]: d e b a 1 1.0 1 a 1 3 3.0 4 b 2 1 NaN 3 c 8 4 In [6]: pdf.sort_index(axis='columns', ignore_index=True) Out[6]: 0 1 b a 1 1.0 1 a 1 3 3.0 4 b 2 1 NaN 3 c 8 4 In [7]: pdf.sort_index(axis='columns', ignore_index=True, ascending=True) Out[7]: 0 1 b a 1 1.0 1 a 1 3 3.0 4 b 2 1 NaN 3 c 8 4 In [8]: pdf.sort_index(axis='columns', ignore_index=True, ascending=False) Out[8]: e d 0 3 1 1 1 2 2 4 8 In [9]: pd.__version__ Out[9]: '2.2.0' ``` ### Issue Description When `ascending=False` the index is being dropped. ### Expected Behavior Not dropping index. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.10.13.final.0 python-bits : 64 OS : Linux OS-release : 5.15.0-91-generic Version : #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.0 numpy : 1.26.3 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 24.0 Cython : 3.0.8 pytest : 7.4.4 hypothesis : 6.98.1 sphinx : 6.2.1 blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2024.2.0 gcsfs : None matplotlib : None numba : 0.59.0 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 14.0.1 pyreadstat : None python-calamine : None pyxlsb : None s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.25 tables : None tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None </details>
[ "Bug", "Index" ]
0
0
0
0
0
0
0
0
[ "cc: @mroeschke ", "~For clarity, `Out[6]:` and `Out[7]:` are incorrect, the resulting index should match `Out[8]`~\r\n\r\nNevermind, I realized `ignore_index=True` applies to the \"columns\" here" ]
2,123,106,172
57,292
Backport PR #56945 on branch 2.2.x (ENH: raise ValueError if invalid period freq pass to asfreq when the index of df is a PeriodIndex)
closed
2024-02-07T14:00:55
2024-02-07T15:12:00
2024-02-07T15:12:00
https://github.com/pandas-dev/pandas/pull/57292
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57292
https://github.com/pandas-dev/pandas/pull/57292
MarcoGorelli
0
(cherry picked from commit cb97ce6e496e7d1df76f06550c0fe8c4590ff3ce) - [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Frequency" ]
0
0
0
0
0
0
0
0
[]
2,122,736,573
57,291
BUG: pd.merge has unexpected behaviour when joining on index / column
open
2024-02-07T10:49:40
2025-03-24T00:49:11
null
https://github.com/pandas-dev/pandas/issues/57291
true
null
null
sledtester
4
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd df1 = pd.DataFrame([ {'seq':i, 'val_1':10+i} for i in range(10) ]) df2 = pd.DataFrame([ {'seq':i+5, 'val_2':10+i+5} for i in range(10) ]) # This produces NaN's in the index (main result in question) pd.merge(df1, df2, left_index=True, right_on='seq', how='left') ``` ### Issue Description When joining two data frames, in this case with a left join, using the left_index, I would expect the left index to be taken for this new data frame, not the values from the right column. As well as being unexpected behaviour, this also results in this case in NaNs in the index, which also has the side effect of changing the index type to float - all in all probably not what was intended. Generate some data <img width="638" alt="image" src="https://github.com/pandas-dev/pandas/assets/90188926/02317b33-30e0-44d2-a51f-559c955319ac"> df1: <img width="147" alt="image" src="https://github.com/pandas-dev/pandas/assets/90188926/6da97274-7c1a-4363-b2ac-1a8bb097119f"> df2: <img width="136" alt="image" src="https://github.com/pandas-dev/pandas/assets/90188926/dcd9ceda-21bb-4341-8ef2-2e1c4925d6a5"> join them: <img width="618" alt="image" src="https://github.com/pandas-dev/pandas/assets/90188926/b3f41136-a7f2-4062-beb6-97906bd31e47"> ### Expected Behavior The resultant dataframe of a left-join with left-index should have the index of the left data frame. ### Installed Versions INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.11.4.final.0 python-bits : 64 OS : Darwin OS-release : 23.2.0 Version : Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:10 PST 2023; root:xnu-10002.61.3~2/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : None LOCALE : None.UTF-8 pandas : 2.2.0 numpy : 1.26.3 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 23.3.2 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : 2.9.9 jinja2 : None IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2024.2.0 gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.12.0 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None
[ "Bug", "Reshaping" ]
0
0
0
0
0
0
0
0
[ "I am new to contributing to open source and I am not very experienced. But I believe these could be the possible solution.\r\n`pd.merge(df1,df2,how='left',left_index=True,right_index=True)`", "take", "take", "Confirmed on main" ]
2,122,411,829
57,290
DOC: CoW User Guide - Previous behavior is current
closed
2024-02-07T07:58:18
2024-03-16T17:25:17
2024-03-16T17:25:16
https://github.com/pandas-dev/pandas/issues/57290
true
null
null
VladimirFokow
2
### Pandas version checks - [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/) ### Location of the documentation https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html#previous-behavior https://github.com/pandas-dev/pandas/blob/main/doc/source/user_guide/copy_on_write.rst?plain=1#L32-L45 ### Documentation problem [This section](https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html#previous-behavior) is intended to show the previous behavior (`<3.0`), however now it runs with pandas 3.0, and thus doesn't demonstrate its intended point of what would happen PREVIOUSLY. And also in the second block of code there, there is `pd.options.mode.copy_on_write = True` which would be unnecessary with pandas `3.0` so can be removed, right? ### Suggested fix for documentation I don't know the correct way to fix it, but such ideas come to mind: - manually write the output for the old behavior - use an older pandas version to run that code when building documentation - set some setting in pandas `>=3.0` that would simulate the old behavior
[ "Docs", "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "Thx for the issue,\r\n\r\nI've just started the process of switching pandas to Copy-on-Write, the docs will need updating as well but it's on my todo list", "updated, so closing here" ]
2,122,338,714
57,289
DOC: fix typo: "two solution"
closed
2024-02-07T07:13:51
2024-02-07T18:05:21
2024-02-07T18:02:24
https://github.com/pandas-dev/pandas/pull/57289
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57289
https://github.com/pandas-dev/pandas/pull/57289
VladimirFokow
1
> There are two potential solution to this: fixed to: > There are two potential solutions to this:
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "Thanks @VladimirFokow " ]
2,122,313,385
57,288
DOC: fix PR02 errors in docstring for pandas.core.groupby.SeriesGroupBy.apply
closed
2024-02-07T06:53:50
2024-02-08T22:21:23
2024-02-08T22:21:12
https://github.com/pandas-dev/pandas/pull/57288
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57288
https://github.com/pandas-dev/pandas/pull/57288
jordan-d-murphy
4
All PR02 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=PR02 pandas.core.groupby.SeriesGroupBy.apply - [x] xref https://github.com/pandas-dev/pandas/issues/57111 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "@mroeschke can you confirm the alignment looks correct now?", "Yup, I just did. Checks should be running again. Thanks for letting me know! ", "pre-commit.ci autofix", "Nice thanks for the quick turnaround @jordan-d-murphy " ]
2,122,254,715
57,287
Fixed BUG: Using NamedTuples with .iloc fails #48188
closed
2024-02-07T06:03:15
2024-02-07T18:03:19
2024-02-07T18:03:18
https://github.com/pandas-dev/pandas/pull/57287
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57287
https://github.com/pandas-dev/pandas/pull/57287
MkMayo
3
- [ ] closes #48188 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Bug", "Indexing" ]
0
0
0
0
0
0
0
0
[ "Thanks @MkMayo for the PR. \r\n\r\nIt appears there is already an open issue for fix this.", "#57004", "Thanks for the PR but as mentioned this is already being worked on in https://github.com/pandas-dev/pandas/pull/57004 so closing in favor of that PR. We can reopen this PR if that one becomes stale" ]
2,122,248,241
57,286
ENH: Add Cumulative Rolling Method for DataFrame
closed
2024-02-07T05:57:01
2024-02-07T08:54:55
2024-02-07T08:54:55
https://github.com/pandas-dev/pandas/issues/57286
true
null
null
lanceyliao
1
### Feature Type - [X] Adding new functionality to pandas - [ ] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description I wish I could use pandas to perform cumulative rolling operations on a DataFrame. ### Feature Description Introduce a new method, say cumrolling(), to DataFrame objects, allowing users to perform cumulative rolling operations similar to the existing rolling() method. The usage would be like df.cumrolling().apply(func). It's worth noting that no window parameter is needed since this is inherently cumulative. ### Alternative Solutions ``` import pandas as pd def custom_cumrolling(df, func): result = pd.DataFrame(index=df.index, columns=df.columns) for i in range(1, len(df) + 1): window_data = df.iloc[:i] result.iloc[i - 1] = func(window_data) return result # Example usage data = { 'A': [1, 2, 3, 4, 5], 'B': [6, 7, 8, 9, 10], 'C': [11, 12, 13, 14, 15] } df = pd.DataFrame(data) print(df) # Define a custom function to apply in the cumulative rolling def custom_function(data): return data.sum() # You can replace this with any custom aggregation logic # Apply custom cumulative rolling function result = custom_cumrolling(df, custom_function) print(result) ``` ### Additional Context _No response_
[ "Enhancement", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "result = df.expanding().sum()\r\nprint(result)" ]
2,121,996,621
57,285
TYP: misc return types
closed
2024-02-07T01:45:34
2024-02-10T20:34:26
2024-02-07T04:55:26
https://github.com/pandas-dev/pandas/pull/57285
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57285
https://github.com/pandas-dev/pandas/pull/57285
twoertwein
1
null
[ "Typing" ]
0
0
0
0
0
0
0
0
[ "Thanks @twoertwein " ]
2,121,809,128
57,284
Added `pyarrow` extra for instructions on silencing the `DeprecationWarning`
closed
2024-02-06T23:03:27
2024-02-22T19:00:15
2024-02-22T18:11:53
https://github.com/pandas-dev/pandas/pull/57284
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57284
https://github.com/pandas-dev/pandas/pull/57284
jamesbraza
3
Changes requested in https://github.com/pandas-dev/pandas/issues/54466#issuecomment-1930675430
[ "Dependencies", "Warnings" ]
0
0
0
0
0
0
0
0
[ "Sorry I missed this, but this was addressed in https://github.com/pandas-dev/pandas/pull/57551. Thanks for the start here but closing", "Sound good @mroeschke . It would be nice to update the messages in the `DeprecationWarning` to mention this extra too, feel free to diff this PR with your PR to see what I had posed", "The warning will be removed in 2.2.1 https://github.com/pandas-dev/pandas/pull/57556" ]
2,121,772,699
57,283
Translate more banned import config to ruff
closed
2024-02-06T22:27:24
2024-03-17T07:53:21
2024-02-13T17:04:00
https://github.com/pandas-dev/pandas/pull/57283
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57283
https://github.com/pandas-dev/pandas/pull/57283
tqa236
1
Translate some config in `unwanted-patterns-in-tests` to `ruff`. I think the main selling point of `ruff` here is just the ease of implementing new rules, like the currently unenabled `pytest.warns` one. The major difference is that `unwanted-patterns-in-tests` is currently only enabled in `pandas/tests` while with this implementation, `TID251` will be enabled globally. There are several approaches we can explore to reconcile the 2 behaviors. - Keep it globally enabled for rule where the number of errors is low (and keep using `pygrep`) for the rest - Use [hierarchical configuration](https://docs.astral.sh/ruff/configuration/#pyprojecttoml-discovery) (I think `pandas` doesn't use it at the moment, so this will be a fairly big change) There's an open issue to track the progress of [flat configuration](https://github.com/astral-sh/ruff/issues/7696), which allows us to keep all rules within 1 config file, but there's not much progress lately.
[ "Code Style" ]
0
0
0
0
0
0
0
0
[ "Thanks @tqa236 " ]
2,121,699,214
57,282
Use ruff to enforce import alias
closed
2024-02-06T21:31:14
2024-03-17T07:53:33
2024-03-05T00:49:52
https://github.com/pandas-dev/pandas/pull/57282
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57282
https://github.com/pandas-dev/pandas/pull/57282
tqa236
3
I replaced the hook `use-pd_array-in-core` with `ruff`'s [`unconventional-import-alias`](https://docs.astral.sh/ruff/rules/unconventional-import-alias/) The `pre-commit` job will fail to show that the check works. It will pass after I enable `exclude: ^pandas/core/api\.py$`. If this change is accepted, I can continue with removing the old hook. As far as I can understand, a major difference is that `scripts/use_pd_array_in_core.py` tries to detect all variants of `pd.<insert anything here>.array` while we must explicitly pass the full path for `ruff` (there's only `pandas.core.construction.array`).
[ "Code Style" ]
0
0
0
0
0
0
0
0
[ "Looks pretty good. Could you address the pre-commit failure?", "@mroeschke I fixed the config and removed the old hook. `pre-commit` passes now. The failed pipelines seem unrelated to this PR.", "Thanks @tqa236 " ]
2,121,629,463
57,281
ENH: show category[dtype]
closed
2024-02-06T20:40:16
2024-02-07T15:22:49
2024-02-06T20:40:31
https://github.com/pandas-dev/pandas/issues/57281
true
null
null
VladimirFokow
1
## (in process of writing it) please comment if it's a good / bad idea ### Feature Type - [ ] Adding new functionality to pandas - [X] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description Would it be good to also show the `Categorie`'s `dtype`, for example like this?: ```py import pandas as pd import numpy as np df = pd.DataFrame({ 'a': pd.Categorical([1, 2, 3]), 'b': pd.Categorical([1, 2, np.nan]), 'b': pd.Categorical(np.array([1, 2, np.nan])), 'c': pd.Categorical(['a', 'b', 'c']) }) print(df.dtypes) ``` Currently: ``` a category b category c category d category dtype: object ``` Proposed: ``` a category<int64> b category<int64> c category<float64> d category<object> dtype: object ``` or whichever alternative looks best, e.g.: ``` category<int64> category[int64] category(int64) category{int64} <int64>category [int64]category (int64)category {int64}category ``` --- ## Advantages of the proposed way: ### - Differentiate `CategoricalDtype` of different different `dtypes` between each other when viewed in `df.dtypes` Inside, each of these categories are actually different `dtypes`, so `category` can be thought of as a "meta-dtype": while two columns of int64 are of the same `dtype`, the columns of different `category` can have different category `dtypes`. `dtype` `"category"` in reality means: one of `CategoricalDtype` objects. While this enhancement wouldn't completely differentiate them, it would do it at least in some cases (when the `dtypes` of their categories are different). --- ### - When merging two categorical columns: more convenience, fewer opportunities for mistakes For example, when merging on a categorical column, this can be a useful hint. Helpful reading: [medium article](https://towardsdatascience.com/staying-sane-while-adopting-pandas-categorical-datatypes-78dbd19dcd8a), section "Merging two categorical columns". In summary: Joining on columns -> produces > cat1 cat2 -> obj > cat1 cat1 -> cat1 While showing the dtypes alone wouldn't completely solve this, this can be a helpful improvement in user experience - to seeing the internal `dtypes` with `df.dtypes`, instead of with `df['column_name'].dtype` and seeing in parenthesis, or `df['column_name'].cat.categories.dtype` or `df['column_name'].dtype.categories.dtype` --- TODO: read that article - any other advantages / quality-of-life improvements of this proposal? --- ### - Conversion from categorical column to normal - unclear reason for error ```py # Preparation of the situation: df['b'] = ad['b'].cat.add_categories('new_cat') # The situation: print(df) # see that data in both `a` and `b` are integers print(df.dtypes) # see that the dtypes both `a` and `b` are "category" -> want to convert df['a'].astype(int) # works df['b'].astype(int) # doesn't work, saying: `ValueError: Cannot cast object dtype to int64` ``` Confusing error: I wanted to cast a categorical - not an object. (although it's quite easy to discover the reason: `print(df['b']) includes "object" The reason: inside of a categorical is an object (although 'new_cat' is an unused category, it still prevents conversion to int). We can know this with: `df['b']` or `df['b'].dtype` --- ### - better clarity `dtypes` inside `Categorical` can have behavior different from `numpy`. Seeing the `dtypes` clearly -> Fewer user surprises ```py pd.Categorical([3, 1, np.nan]) # CategoricalDtype int64 # while: pd.Categorical(np.array([1, 2, np.nan])) # CategoricalDtype of type float64 ``` --- ## Drawbacks: - longer, not so clean `dtype` to read - can still be confusing: even in cases where `category<dtype>` is same, `CategoryDtypes` can still be different objects --- ## What do you think? What are some of the advantages or drawbacks of showing the `dtypes` of categories? Is this interesting at all? ### Feature Description When a df contains a categorical column, and the user prints `df.dtypes`, instead of ``` category ``` show: ``` category[dtype] ``` where dtype is the `categories_dtype` when printing `ad['column_name'].dtype` <br /> ### Alternative Solutions (that currently exist) ```py df['a'] # last line of output contains the dtype: Categories (3, int64): [1, 2, 3] ``` Or any of these also show the internal `dtype`: ```py df['a'].dtype # CategoricalDtype(categories=['a', 'b', 'c'], ordered=False, categories_dtype=int64) df['a'].cat.categories # Index([1, 2, 3], dtype='int64') df['a'].cat.categories.dtype # dtype('int64') df['a'].dtype.categories # Index([1, 2, 3], dtype='int64') df['a'].dtype.categories.dtype # dtype('int64') ``` ### Additional Context #48515 wanted the ability to set the cat dtype, my request is just for displaying it #57259 wants to fix the docs for categorical dtype equality - `dtype` is important for their equality, so seeing it is useful (although insufficient, still useful)
[ "Enhancement", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "currently in status of writing it, can reopen when ready;\r\n\r\n## please comment: is it interesting? Should I continue working on it? Is it a good / bad idea?" ]
2,121,468,026
57,280
DEPR: Positional arguments in Series.to_markdown/string
closed
2024-02-06T18:53:15
2024-02-17T13:11:09
2024-02-17T13:11:09
https://github.com/pandas-dev/pandas/issues/57280
true
null
null
mroeschke
1
While most method were captured in https://github.com/pandas-dev/pandas/issues/54229, `Series.to_string` and `Series.to_markdown` were missed
[ "IO Data", "Deprecate" ]
0
0
0
0
0
0
0
0
[ "take" ]
2,121,451,412
57,279
CLN: Make first argument in IO writers keyword only; remove gbq
closed
2024-02-06T18:43:36
2024-02-07T04:50:00
2024-02-07T04:09:13
https://github.com/pandas-dev/pandas/pull/57279
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57279
https://github.com/pandas-dev/pandas/pull/57279
mroeschke
1
xref https://github.com/pandas-dev/pandas/issues/54229, https://github.com/pandas-dev/pandas/pull/55868
[ "IO Data" ]
0
0
0
0
0
0
0
0
[ "Thanks @mroeschke " ]
2,121,413,593
57,278
Remove codecov CI output
closed
2024-02-06T18:18:54
2024-02-06T20:11:27
2024-02-06T19:48:01
https://github.com/pandas-dev/pandas/pull/57278
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57278
https://github.com/pandas-dev/pandas/pull/57278
WillAyd
1
null
[ "CI" ]
0
0
0
0
0
0
0
0
[ "Thanks @WillAyd " ]
2,120,655,410
57,277
DOC: Wrong generalization about slice indexing
closed
2024-02-06T12:25:29
2024-04-02T00:37:54
2024-04-02T00:37:54
https://github.com/pandas-dev/pandas/issues/57277
true
null
null
memeplex
2
### Pandas version checks - [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/) ### Location of the documentation https://pandas.pydata.org/pandas-docs/version/2.0.2/user_guide/indexing.html#slicing-ranges ### Documentation problem > With Series, the syntax works exactly as with an ndarray, returning a slice of the values and the corresponding labels And then shows examples of slice indexing `df[i:j]` where `i` and `j` are integers, and all of them behave as `df.iloc[i:j]` (that is, "exactly as with an ndarray"). But there is an exception (which I can't make sense of and fortunately is deprecated): ``` > pd.Series([1, 2, 3], [3., 2., 1.])[:3] 3.0 1 dtype: int64 ``` So, when the index is float, integer slices behave loc-like. Please document this exception in a callout because it's dangerous to assume that the iloc-like behavior is general. BTW, could someone give a rationale for this behavior? Is there a general rule that ends up in this weird situation, like "if index and slice are int -> iloc, if not then if slice is of the type of the index -> loc else if slice is int -> iloc else fail", and then an int slice is taken to be of the type of a float index? ### Suggested fix for documentation Document this exception in a callout because it's dangerous to assume that the iloc-like behavior is general.
[ "Docs", "Indexing" ]
0
0
0
0
0
0
0
0
[ "> BTW, could someone give a rationale for this behavior?\r\n\r\nI guess the convoluted history that https://github.com/pandas-dev/pandas/issues/49612 tells explains it.\r\n\r\n1. Initially there was the intention to make all int-slice indexing label based but the deprecations weren't sufficient and at that point doing so would have broken many things.\r\n2. So it was decided that it was ok if int-slice indexing was consistent per se (always position based) despite being somewhat inconsistent wrt to other types of indexing (s[i:j] iloc-like vs s[i] or s[[i,j]] loc-like).\r\n3. But float indexes were/are an exception for some historical reason (out of curiosity, which one?). So this case was deprecated.\r\n\r\nThat said, I believe that the documentation should be explicit about this exception until the deprecation is actually enforced.", "take" ]
2,120,515,651
57,276
BUG: BlockManager.references_same_values not working with object-dtype block that has reference to an Index
closed
2024-02-06T11:07:09
2024-02-10T21:10:23
2024-02-10T21:10:23
https://github.com/pandas-dev/pandas/issues/57276
true
null
null
jorisvandenbossche
1
On main, the following snippet fails: ```python df = pd.DataFrame({'A': ['a', 'b', 'c', 'd'], 'B': [1, 2, 3, 4], 'C': ['a', 'a', 'b', 'b']}) df = df.set_index("A") key = df["C"] df.groupby(key, observed=True) ``` with ``` File ~/scipy/pandas/pandas/core/internals/managers.py:342, in BaseBlockManager.references_same_values(self, mgr, blkno) 337 """ 338 Checks if two blocks from two different block managers reference the 339 same underlying values. 340 """ 341 ref = weakref.ref(self.blocks[blkno]) --> 342 return ref in mgr.blocks[blkno].refs.referenced_blocks ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ``` I don't yet fully understand why the list containment check results in that kind of error (I would expect it just does `==` checks on the individual weakref objects and then checks if any of them is True) But it seems to be triggered by at least 1) the index being constructed from a column (if the `df` is created with an index from scratch (passing `index=pd.Index(['a', 'b', 'c', 'd'])`), it doesn't trigger this), and 2) the index being object dtype (when trying with an integer column set as index, it also doesn't happen). So following two examples pass: ```python df = pd.DataFrame({'B': [1, 2, 3, 4], 'C': ['a', 'a', 'b', 'b']}, index=pd.Index(['a', 'b', 'c', 'd'], name="A")) key = df["C"] df.groupby(key, observed=True) df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [1, 2, 3, 4], 'C': ['a', 'a', 'b', 'b']}) df = df.set_index("A") key = df["C"] df.groupby(key, observed=True) ``` (this is also all without enabling CoW, we pass by that code path regardless) cc @phofl I suppose this is originally caused by https://github.com/pandas-dev/pandas/pull/51442, but we never noticed it. The same snippet also raises another error on 2.2.0 (`ValueError: buffer source array is read-only` in `comp_method_OBJECT_ARRAY`)
[ "Bug", "Copy / view semantics" ]
0
0
0
0
0
0
0
0
[ "> I don't yet fully understand why the list containment check results in that kind of error (I would expect it just does `==` checks on the individual weakref objects and then checks if any of them is True)\r\n\r\nAh, but that is because the weakref object equality defers to the referenced objects if they are still alive. For Blocks that is fine (they don't have a custom `__eq__`, so equality falls back to identity), but not for Index objects, which do element-wise equality. The same is true for hashing of weakref objects, which I now remember was the reason we can't just use a set of weakrefs, because Index is unhashable (and thus so is a weakref to an Index object).\r\n\r\n```\r\nIn [23]: %debug\r\n> /home/joris/scipy/pandas/pandas/core/internals/managers.py(343)references_same_values()\r\n 342 ref = weakref.ref(self.blocks[blkno])\r\n--> 343 return ref in mgr.blocks[blkno].refs.referenced_blocks\r\n\r\nipdb> ref\r\n<weakref at 0x7f7322527ec0; to 'NumpyBlock' at 0x7f73221c8290>\r\nipdb> mgr.blocks[blkno].refs.referenced_blocks\r\n[<weakref at 0x7f73205b3920; dead>, <weakref at 0x7f7323f33a10; dead>, <weakref at 0x7f73205b3b00; dead>, <weakref at 0x7f7320c2e520; to 'Index' at 0x7f7320a17990>, <weakref at 0x7f7320c2e700; to 'NumpyBlock' at 0x7f73205ca1b0>, <weakref at 0x7f7322527ec0; to 'NumpyBlock' at 0x7f73221c8290>, <weakref at 0x7f7321765030; to 'NumpyBlock' at 0x7f7320618530>]\r\nipdb> ref == mgr.blocks[blkno].refs.referenced_blocks[0]\r\nFalse\r\nipdb> ref == mgr.blocks[blkno].refs.referenced_blocks[3]\r\narray([False, False, False, False])\r\nipdb> ref == mgr.blocks[blkno].refs.referenced_blocks[5]\r\nTrue\r\n```\r\n\r\nNot yet fully sure why this doesn't happen for a numeric index, though. Are we adding the Index weakref wrongly?\r\n\r\nProbably a separate issue, but the following difference seems a bit suspicious:\r\n\r\n```\r\n# column A set as index is object dtype\r\nIn [2]: df = pd.DataFrame({'A': ['a', 'b', 'c', 'd'], 'B': [1, 2, 3, 4], 'C': ['a', 'a', 'b', 'b']})\r\n ...: df = df.set_index(\"A\")\r\n ...: key = df[\"C\"]\r\n\r\nIn [4]: key._mgr._block.refs.referenced_blocks\r\nOut[4]: \r\n[<weakref at 0x7f33be6df9c0; dead>,\r\n <weakref at 0x7f336a8a2c50; dead>,\r\n <weakref at 0x7f336a8a3920; dead>,\r\n <weakref at 0x7f336a8e4f90; to 'Index' at 0x7f336a83b310>,\r\n <weakref at 0x7f336a8a0180; to 'NumpyBlock' at 0x7f336a6acd10>,\r\n <weakref at 0x7f336a8e72e0; to 'NumpyBlock' at 0x7f33be4b3f50>]\r\n\r\n# column A set as index is now integer dtype\r\nIn [5]: df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [1, 2, 3, 4], 'C': ['a', 'a', 'b', 'b']})\r\n ...: df = df.set_index(\"A\")\r\n ...: key = df[\"C\"]\r\n\r\nIn [6]: key._mgr._block.refs.referenced_blocks\r\nOut[6]: \r\n[<weakref at 0x7f33636aa7f0; dead>,\r\n <weakref at 0x7f336a8a3970; dead>,\r\n <weakref at 0x7f33636aa160; to 'NumpyBlock' at 0x7f336322af90>,\r\n <weakref at 0x7f3363158130; to 'NumpyBlock' at 0x7f336a6acbf0>]\r\n```\r\n\r\n" ]
2,120,453,907
57,275
DEPR: disallow parsing datetimes with mixed time zones unless `utc=True`
closed
2024-02-06T10:35:39
2024-02-19T23:00:35
2024-02-19T23:00:35
https://github.com/pandas-dev/pandas/pull/57275
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57275
https://github.com/pandas-dev/pandas/pull/57275
natmokval
2
xref #54014 enforced deprecation disallowing parsing datetimes with mixed time zones unless user passes `utc=True` to `to_datetime`
[ "Datetime", "Deprecate" ]
0
0
0
0
0
0
0
0
[ "@MarcoGorelli, could you please take a look at this PR?", "Thanks @natmokval " ]
2,119,990,590
57,274
DOC: Poor Documentation
closed
2024-02-06T05:27:01
2024-02-06T05:28:33
2024-02-06T05:28:32
https://github.com/pandas-dev/pandas/issues/57274
true
null
null
Mechanicalbird
1
### Pandas version checks - [ ] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/) ### Location of the documentation Please provide documentation how to run this library and a set of the commands needed for that. you have very poor documentation, very simple please provide instruction to run an example. ### Documentation problem Please provide documentation how to run this library and a set of the commands needed for that. you have very poor documentation, very simple please provide instruction to run an example. ### Suggested fix for documentation Please provide documentation how to run this library and a set of the commands needed for that. you have very poor documentation, very simple please provide instruction to run an example.
[ "Docs", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "Please provide documentation how to run this library and a set of the commands needed for that.\r\n\r\nyou have very poor documentation, very simple please provide instruction to run an example. " ]
2,119,921,571
57,273
DOC: Add notice and example for `CategoricalDtype` with different ``categories_dtype``
closed
2024-02-06T04:07:32
2024-02-17T14:44:04
2024-02-17T12:25:57
https://github.com/pandas-dev/pandas/pull/57273
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57273
https://github.com/pandas-dev/pandas/pull/57273
luke396
9
- [x] closes #57259 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "Categorical" ]
0
0
0
0
0
0
0
0
[ "Thanks @luke396 !\r\n\r\nI was hoping that this part would be edited:\r\n\r\n```rst\r\nTwo instances of :class:`~pandas.api.types.CategoricalDtype` compare equal\r\nwhenever they have the same categories and order. When comparing two\r\nunordered categoricals, the order of the ``categories`` is not considered.\r\n```\r\n\r\nto be a complete and definitive definition, covering all cases right here.\r\n\r\n(instead of adding examples and having the user then guess the actual rules)\r\n", "More generally, I am confused:\r\n\r\n```rst\r\nA categorical's type is fully described by\r\n1. ``categories``: a sequence of unique values and no missing values\r\n2. ``ordered``: a boolean\r\n```\r\n\r\n... If the `CategoricalDtype` is \"fully described\" by ``categories`` and ``order``, \r\nand ``categories`` is defined as a \"sequence of unique values and no missing values\"\r\n--> `[]` is a \"sequence of unique values and no missing values\"\r\n (yes, it's empty, but it is a sequence of 0 unique values and doesn't contain NaNs (the missing values)) \r\n--> there is no `dtype` anywhere in this definition.. \r\nSo should this description be corrected as well? \r\n\r\nThese should be good precise definitions giving an accurate conceptual understanding.\r\n ", "\r\n> ```\r\n> Two instances of :class:`~pandas.api.types.CategoricalDtype` compare equal\r\n> whenever they have the same categories and order. When comparing two\r\n> unordered categoricals, the order of the ``categories`` is not considered.\r\n> ```\r\n\r\nThank you, @VladimirFokow, for your advice on the PR. I hadn't considered it as thoroughly as you did. At the moment, the example in the file doesn't suit my needs well, which is why the PR is still in progress. Have to admit it, I actually don't have the same accurate and comprehensive understanding of `Categorical` as you do.\r\n> These should be good precise definitions giving an accurate conceptual understanding.\r\n\r\nYou've shown great consideration in enhancing the docstring, and your insights could be used to open a new pull request aimed at improving the general description further.", "Maybe they meant that a `Categorical`👈 (not `CategoricalDtype`) is partly described by `.categories`... \r\nBut in this case, `categories` is NOT a sequence. \r\nIt's an `Index` (containing the categories, and of a certain `dtype` which is determined... automatically? - even if constructed from a numpy array of objects yet all integers - the dtype of this index will be int, not object... \r\n\r\nHow is this dtype determined - completely disregarding the numpy dtype and just looking at the actual values? How to operate with it - can we change it / what are the best practices when dealing with problems connected to it)\r\n\r\n---\r\n\r\nupd: Maybe what they meant here is a purely conceptual description, because after it they say:\r\n> This information can be stored in a CategoricalDtype.", "Hi @rhshadrach, could you please review the PR and provide some comments for improvement?\r\n", "@rhshadrach Thanks for your prompt review! I have updated the PR based on your comments.", "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57273/", "Thanks @luke396 " ]