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,174,911,554
57,772
Enforce numpydoc's GL05
closed
2024-03-07T22:15:45
2024-03-17T07:53:34
2024-03-07T23:41:37
https://github.com/pandas-dev/pandas/pull/57772
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57772
https://github.com/pandas-dev/pandas/pull/57772
tqa236
1
This error code was shadowed by another with the same name in `pandas`. The old error code was renamed to `PD01` in https://github.com/pandas-dev/pandas/pull/57767 I think `numpydoc`'s GL05 might also be interesting to enforce ``` "GL05": 'Tabs found at the start of line "{line_with_tabs}", please use ' "whitespace only", ```
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "Thanks @tqa236 " ]
2,174,815,824
57,771
DOC: Fix PR01 and SA01 errors in pandas.ExcelFile
closed
2024-03-07T21:17:12
2024-03-28T22:22:51
2024-03-28T22:21:39
https://github.com/pandas-dev/pandas/pull/57771
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57771
https://github.com/pandas-dev/pandas/pull/57771
iridiium
5
- [x] xref #57438 - [x] xref #57417 - [ ] [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", "IO Excel" ]
0
0
0
0
0
0
0
0
[ "Thanks for the PR @iridiium - looks like docstring validation is failing here and needs fixed.", "I am aware of and currently fixing the issues, sorry for requesting reviews when unneeded.", "@iridiium we changed how we specify the pending errors in `code_checks.sh` and you'll have to resolve the conflicts now, sorry about it.", "@iridiium if you want I can help with the updating of the error exceptions in the shell script. Just let me know", "> @iridiium if you want I can help with the updating of the error exceptions in the shell script. Just let me know\r\n\r\n~~Sorry, I've been a bit busy lately, although I will try and work on this soon. I haven't been following the changes much and am not too sure on how to update this, how would I do so?~~\r\n\r\nI haven't changed much, so I'd rather start fresh" ]
2,174,809,670
57,770
PERF: RangeIndex.__getitem__ with integers return RangeIndex
closed
2024-03-07T21:13:56
2024-03-12T23:51:17
2024-03-12T23:51:14
https://github.com/pandas-dev/pandas/pull/57770
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57770
https://github.com/pandas-dev/pandas/pull/57770
mroeschke
2
Builds on #57752 Discovered in #57441
[ "Indexing", "Performance", "Index" ]
0
0
0
0
0
0
0
0
[ "This looks to have a lot of overlap with https://github.com/pandas-dev/pandas/pull/57752 - is that expected?", "> This looks to have a lot of overlap with #57752 - is that expected?\r\n\r\nYes, this relies on some of the changes in https://github.com/pandas-dev/pandas/pull/57752" ]
2,174,800,030
57,769
Backport PR #57665 on branch 2.2.x (BUG: interchange protocol with nullable datatypes a non-null validity)
closed
2024-03-07T21:08:40
2024-03-08T07:02:16
2024-03-08T07:02:16
https://github.com/pandas-dev/pandas/pull/57769
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57769
https://github.com/pandas-dev/pandas/pull/57769
MarcoGorelli
0
backports #57665
[ "Interchange" ]
0
0
0
0
0
0
0
0
[]
2,174,773,848
57,768
PERF: Return RangeIndex columns instead of Index for str.partition with ArrowDtype
closed
2024-03-07T20:51:14
2024-03-11T04:32:42
2024-03-11T03:22:43
https://github.com/pandas-dev/pandas/pull/57768
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57768
https://github.com/pandas-dev/pandas/pull/57768
mroeschke
0
Discovered in https://github.com/pandas-dev/pandas/pull/57441
[ "Performance", "Index" ]
0
0
0
0
0
0
0
0
[]
2,174,574,937
57,767
Validate docstring error code
closed
2024-03-07T19:05:31
2024-03-07T21:32:41
2024-03-07T21:15:50
https://github.com/pandas-dev/pandas/pull/57767
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57767
https://github.com/pandas-dev/pandas/pull/57767
tqa236
1
This PR does 2 things - Validate that all `pandas` error codes are not overlapped with `numpydoc`'s - Validate that all input error codes are valid I wonder if this is a welcome change? Currently, I can detect 1 duplicated error code.
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "Thanks @tqa236 " ]
2,174,369,470
57,766
Bump ruff to latest version
closed
2024-03-07T17:23:25
2024-03-07T22:56:38
2024-03-07T22:55:10
https://github.com/pandas-dev/pandas/pull/57766
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57766
https://github.com/pandas-dev/pandas/pull/57766
tqa236
6
Bump `ruff` to the latest version in a separate PR because of the big formatting change.
[ "Code Style" ]
0
0
0
0
0
0
0
0
[ "@mroeschke I wonder if it's reasonable to deprecate EX03 in favor of `ruff`'s autoformat of docstrings. \r\n\r\nIf I understand correctly, EX03 is used to validate that a code block in a docstring follows PEP8. Currently EX03 is using `flake8` under the hood, which is no longer compatible with `ruff` (and `black`)'s 2024 style. \r\n\r\nIn my opinion, we can just use `ruff` here. This should allow us to remove `flake8` as a dev requirement as well.\r\n\r\n", "> I wonder if it's reasonable to deprecate EX03 in favor of ruff's autoformat of docstrings.\r\n\r\nI think there's momentum towards removing EX03. We can't right now since some docstrings are dynamically generated and `flake8` is performed those in a separate job (see `scripts/validate_docstrings.py`)", "@mroeschke how about adding E704 (Multiple statements on one line (def)) to the list of ignored errors for EX03? Currently there are `\"--ignore=E203,E3,W503,W504,E402,E731,E128,E124\"`", "> how about adding E704 (Multiple statements on one line (def)) to the list of ignored errors for EX03?\r\n\r\nIf that's the code that conflict with ruff's formating, that sounds good", "@mroeschke this PR should be ready for review, apart from the second commit, which is automatic, the rest are manual small fixes", "Thanks @tqa236 " ]
2,174,333,453
57,765
BUG: Setting a numpy array as a column in Pandas uses only the first column of the array.
open
2024-03-07T17:02:55
2025-07-15T20:42:58
null
https://github.com/pandas-dev/pandas/issues/57765
true
null
null
kgourgou
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 import numpy as np p = np.array([ [1,2,3], [1,2,3] ]) df = pandas.DataFrame(columns=['n', 'p']) df['n'] = np.array([0,0]) df['p'] = p print(df) ``` ``` n p 0 0 1 1 0 1 ``` ### Issue Description Passing the columns as separate arrays, but one of the arrays has the wrong dimensions Nx2 instead of Nx1. In that case, the dataframe column 'p' can be assigned that Nx2 array, but only the first column of the array is actually assigned to 'p'. While this is hard to happen by accident, it's not impossible. ### Expected Behavior Either store each row of the array to the corresponding row of the dataframe or raise a warning/error for trying to store a NxM array as a column. See for example: ```python import pandas import numpy as np p = [ [1,2], [1,2] ] df = pandas.DataFrame(columns=['n', 'p']) df['n'] = [0,0] df['p'] = p print(df) ``` ``` n p 0 0 [1, 2] 1 0 [1, 2] ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.10.12.final.0 python-bits : 64 OS : Linux OS-release : 6.1.58+ Version : #1 SMP PREEMPT_DYNAMIC Sat Nov 18 15:31:17 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.1 numpy : 1.25.2 pytz : 2023.4 dateutil : 2.8.2 setuptools : 67.7.2 pip : 23.1.2 Cython : 3.0.8 pytest : 7.4.4 hypothesis : None sphinx : 5.0.2 blosc : None feather : None xlsxwriter : None lxml.etree : 4.9.4 html5lib : 1.1 pymysql : None psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : 7.34.0 pandas_datareader : 0.10.0 adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2023.6.0 gcsfs : 2023.6.0 matplotlib : 3.7.1 numba : 0.58.1 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pandas_gbq : 0.19.2 pyarrow : 14.0.2 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.11.4 sqlalchemy : 2.0.28 tables : 3.8.0 tabulate : 0.9.0 xarray : 2023.7.0 xlrd : 2.0.1 zstandard : None tzdata : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Indexing", "Needs Discussion", "Nested Data" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. The current behavior does look problematic to me, and the expected behavior seems reasonable, but I think this needs some more discussion.", "Should raise", "It is indeed an interesting issue, worth exploring the implicit handling within `pandas`, as well as adjusting strategies. I will continue to keep an eye on it. The following is just a method of avoidance.\r\n\r\nThe array `p` is a two-dimensional array, which will cause the issue. If you want to add each sub-array in the `p` array as independent rows to the 'p' column, you should initialize it directly when creating the `DataFrame`, instead of adding the column afterwards.\r\n\r\n```\r\nimport pandas as pd\r\nimport numpy as np\r\n\r\np = np.array([\r\n [1, 2, 3],\r\n [1, 2, 3]\r\n])\r\n\r\n# Create a DataFrame containing the 'p' array and initialize the 'n' column\r\ndf = pd.DataFrame({\r\n 'n': [0, 0],\r\n 'p': list(map(list, p)) # Convert each sub-array to a list and assign as independent rows\r\n})\r\n\r\nprint(df)\r\n```\r\n\r\n```\r\n n p\r\n0 0 [1, 2, 3]\r\n1 0 [1, 2, 3]\r\n```\r\n\r\nIn this corrected code, `list(map(list, p))` is converting each sub-array in the two-dimensional `NumPy` array to a list. Then, we can assign these lists as independent rows to the 'p' column of the DataFrame.", "Thank you, @TinusChen, that is reasonable. \r\n\r\nThe context for this issue is that I was inspecting a codebase that was accidentally passing an Nx2 array instead of an Nx1 to the frame. Now because no warning was raised and because only the first column of the array was assigned, nobody was the wiser to what was happening. \r\n", "I think I agree with @jbrockmendel " ]
2,173,990,499
57,764
BUG: PyArrow dtypes were not supported in the interchange protocol
closed
2024-03-07T14:26:05
2024-04-10T12:08:23
2024-03-20T21:10:55
https://github.com/pandas-dev/pandas/pull/57764
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57764
https://github.com/pandas-dev/pandas/pull/57764
MarcoGorelli
6
fixes a few things: - closes #57762 - closes #57761 - closes #57664
[ "Interchange" ]
0
0
0
0
0
0
0
0
[ "thanks for your review! I've updated an simplified a bit", "Thanks @MarcoGorelli ", "thanks both!\r\n\r\n> keep chipping away\r\n\r\n😄 we're getting there\r\n\r\nI didn't set a milestone, is it OK if I backport this to 2.2.x?", "@meeseeksmachine please backport to 2.2.x", "@meeseeksdev backport 2.2.x", "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 710720e6555c779a6539354ebae59b1a649cebb3\n```\n\n3. You will likely have some merge/cherry-pick conflict here, fix them and commit:\n\n```\ngit commit -am 'Backport PR #57764: BUG: PyArrow dtypes were not supported in the interchange protocol'\n```\n\n4. Push to a named branch:\n\n```\ngit push YOURFORK 2.2.x:auto-backport-of-pr-57764-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 #57764 on branch 2.2.x (BUG: PyArrow dtypes were not supported in the interchange protocol)\"\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,173,796,717
57,763
Backport PR #57759 on branch 2.2.x (DOC: add whatsnew for v2.2.2)
closed
2024-03-07T12:52:13
2024-03-07T17:13:45
2024-03-07T17:13:45
https://github.com/pandas-dev/pandas/pull/57763
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57763
https://github.com/pandas-dev/pandas/pull/57763
meeseeksmachine
0
Backport PR #57759: DOC: add whatsnew for v2.2.2
[ "Docs" ]
0
0
0
0
0
0
0
0
[]
2,173,463,666
57,762
BUG: interchange buffer show bytemask (instead of bitmask) validity for `'string[pyarrow]'`
closed
2024-03-07T09:59:13
2024-03-20T21:10:56
2024-03-20T21:10:56
https://github.com/pandas-dev/pandas/issues/57762
true
null
null
MarcoGorelli
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 = pd.DataFrame({"a": ["x", None]}, dtype="large_string[pyarrow]") print(df.__dataframe__().get_column_by_name('a').get_buffers()) print(df['a'].array._pa_array.chunks[0].buffers()) print(pai.from_dataframe(df)) ``` ### Issue Description This shows ``` {'data': (PandasBuffer({'bufsize': 1, 'ptr': 140019260284416, 'device': 'CPU'}), (<DtypeKind.UINT: 1>, 8, 'C', '=')), 'validity': (PandasBuffer({'bufsize': 2, 'ptr': 94883712583296, 'device': 'CPU'}), (<DtypeKind.BOOL: 20>, 8, 'b', '=')), 'offsets': (PandasBuffer({'bufsize': 24, 'ptr': 94883723016784, 'device': 'CPU'}), (<DtypeKind.INT: 0>, 64, 'l', '='))} [<pyarrow.Buffer address=0x7f58c8608040 size=1 is_cpu=True is_mutable=True>, <pyarrow.Buffer address=0x7f58c8608000 size=24 is_cpu=True is_mutable=True>, <pyarrow.Buffer address=0x7f58c8608080 size=1 is_cpu=True is_mutable=True>] ``` ### Expected Behavior I think ``` {'data': (PandasBuffer({'bufsize': 1, 'ptr': 140019260284416, 'device': 'CPU'}), (<DtypeKind.UINT: 1>, 8, 'C', '=')), 'validity': (PandasBuffer({'bufsize': 1, 'ptr': 94883712583296, 'device': 'CPU'}), (<DtypeKind.BOOL: 20>, 1, 'b', '=')), 'offsets': (PandasBuffer({'bufsize': 24, 'ptr': 94883723016784, 'device': 'CPU'}), (<DtypeKind.INT: 0>, 64, 'l', '='))} [<pyarrow.Buffer address=0x7f58c8608040 size=2 is_cpu=True is_mutable=True>, <pyarrow.Buffer address=0x7f58c8608000 size=24 is_cpu=True is_mutable=True>, <pyarrow.Buffer address=0x7f58c8608080 size=1 is_cpu=True is_mutable=True>] ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : b033ca94e7ae6e1320c9d65a8163bd0a6049f40a python : 3.10.12.final.0 python-bits : 64 OS : Linux OS-release : 5.15.146.1-microsoft-standard-WSL2 Version : #1 SMP Thu Jan 11 04:09:03 UTC 2024 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.1.0.dev0+761.gb033ca94e7 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.1.1 pip : 24.0 Cython : 3.0.8 pytest : 8.0.2 hypothesis : 6.98.15 sphinx : 7.2.6 blosc : None feather : None xlsxwriter : 3.2.0 lxml.etree : 5.1.0 html5lib : 1.1 pymysql : 1.4.6 psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : 8.22.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.8 fastparquet : 2024.2.0 fsspec : 2024.2.0 gcsfs : 2024.2.0 matplotlib : 3.8.3 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pyarrow : 15.0.0 pyreadstat : 1.2.6 python-calamine : None pyxlsb : 1.0.10 s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.27 tables : 3.9.2 tabulate : 0.9.0 xarray : 2024.2.0 xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2024.1 qtpy : 2.4.1 pyqt5 : None </details>
[ "Bug", "Interchange" ]
0
0
0
0
0
0
0
0
[]
2,173,441,344
57,761
BUG: validity of interchange column is incorrectly set to Some for 'large-string[pyarrow]'
closed
2024-03-07T09:49:14
2024-03-20T21:10:57
2024-03-20T21:10:57
https://github.com/pandas-dev/pandas/issues/57761
true
null
null
MarcoGorelli
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 = pd.DataFrame({"a": ["x"]}, dtype="large_string[pyarrow]") print(df.__dataframe__().get_column_by_name('a').get_buffers()) print(df['a'].array._pa_array.chunks[0].buffers()) ``` ### Issue Description this outputs ``` {'data': (PandasBuffer({'bufsize': 1, 'ptr': 140384569941504, 'device': 'CPU'}), (<DtypeKind.UINT: 1>, 8, 'C', '=')), 'validity': (PandasBuffer({'bufsize': 1, 'ptr': 94849242700288, 'device': 'CPU'}), (<DtypeKind.BOOL: 20>, 8, 'b', '=')), 'offsets': (PandasBuffer({'bufsize': 16, 'ptr': 94849235835952, 'device': 'CPU'}), (<DtypeKind.INT: 0>, 64, 'l', '='))} [None, <pyarrow.Buffer address=0x7fadd6808000 size=16 is_cpu=True is_mutable=True>, <pyarrow.Buffer address=0x7fadd6808080 size=1 is_cpu=True is_mutable=True>] ``` ### Expected Behavior ``` {'data': (PandasBuffer({'bufsize': 1, 'ptr': 140384569941504, 'device': 'CPU'}), (<DtypeKind.UINT: 1>, 8, 'C', '=')), 'validity': None, 'offsets': (PandasBuffer({'bufsize': 16, 'ptr': 94849235835952, 'device': 'CPU'}), (<DtypeKind.INT: 0>, 64, 'l', '='))} [None, <pyarrow.Buffer address=0x7fadd6808000 size=16 is_cpu=True is_mutable=True>, <pyarrow.Buffer address=0x7fadd6808080 size=1 is_cpu=True is_mutable=True>] ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : b033ca94e7ae6e1320c9d65a8163bd0a6049f40a python : 3.10.12.final.0 python-bits : 64 OS : Linux OS-release : 5.15.146.1-microsoft-standard-WSL2 Version : #1 SMP Thu Jan 11 04:09:03 UTC 2024 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.1.0.dev0+761.gb033ca94e7 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.1.1 pip : 24.0 Cython : 3.0.8 pytest : 8.0.2 hypothesis : 6.98.15 sphinx : 7.2.6 blosc : None feather : None xlsxwriter : 3.2.0 lxml.etree : 5.1.0 html5lib : 1.1 pymysql : 1.4.6 psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : 8.22.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.8 fastparquet : 2024.2.0 fsspec : 2024.2.0 gcsfs : 2024.2.0 matplotlib : 3.8.3 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pyarrow : 15.0.0 pyreadstat : 1.2.6 python-calamine : None pyxlsb : 1.0.10 s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.27 tables : 3.9.2 tabulate : 0.9.0 xarray : 2024.2.0 xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2024.1 qtpy : 2.4.1 pyqt5 : None </details>
[ "Bug", "Interchange" ]
0
0
0
0
0
0
0
0
[]
2,173,431,071
57,760
CLN: enforce deprecation of the `method` keyword on `df.fillna`
closed
2024-03-07T09:45:25
2024-03-14T21:08:20
2024-03-14T16:19:19
https://github.com/pandas-dev/pandas/pull/57760
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57760
https://github.com/pandas-dev/pandas/pull/57760
natmokval
3
xref #53496 enforced deprecation of the `method` keyword on `df.fillna/ser.fillna`
[ "Clean", "Transformations" ]
0
0
0
0
0
0
0
0
[ "I enforced deprecation of the `method` keyword on `df.fillna/ser.fillna`. We deprecated the `method` keyword on `EA.fillna` as well. Is it OK if I enforce this deprecation in separate PR?\r\n\r\n@jbrockmendel, could you please take a look at this PR? I think CI failures are unrelated to my changes.\r\n\r\n", "Thanks @natmokval ", "Thanks @mroeschke for reviewing this PR. " ]
2,173,397,024
57,759
DOC: add whatsnew for v2.2.2
closed
2024-03-07T09:28:42
2024-03-07T12:51:10
2024-03-07T12:51:10
https://github.com/pandas-dev/pandas/pull/57759
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57759
https://github.com/pandas-dev/pandas/pull/57759
MarcoGorelli
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.
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "> lgtm, but is removing the imports here intentional?\r\n\r\nruff's failing on `main`, I think just from some prs being merged in close succession" ]
2,173,293,118
57,758
BUG: DataFrame Interchange Protocol errors on Boolean columns
closed
2024-03-07T08:38:04
2024-03-27T17:48:23
2024-03-27T17:48:16
https://github.com/pandas-dev/pandas/pull/57758
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57758
https://github.com/pandas-dev/pandas/pull/57758
MarcoGorelli
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. closes #55332 ~~needs rebasing onto #57764~~
[ "Interchange" ]
0
0
0
0
0
0
0
0
[ "Thanks @MarcoGorelli " ]
2,172,855,399
57,757
CLN: Enforce deprecation of passing a dict to SeriesGroupBy.agg
closed
2024-03-07T03:12:29
2024-03-07T21:09:12
2024-03-07T04:40:31
https://github.com/pandas-dev/pandas/pull/57757
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57757
https://github.com/pandas-dev/pandas/pull/57757
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: #52268
[ "Groupby", "Clean", "Apply" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,172,836,515
57,756
CLN: Enforce deprecation of DataFrameGroupBy.dtypes and Grouper attrs
closed
2024-03-07T02:57:27
2024-03-07T21:09:05
2024-03-07T04:41:13
https://github.com/pandas-dev/pandas/pull/57756
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57756
https://github.com/pandas-dev/pandas/pull/57756
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: #51206, #51182, and #51997
[ "Groupby", "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach. Nice to see all these go! " ]
2,172,788,318
57,755
PERF/CLN: Preserve `concat(keys=range)` RangeIndex level in the result
closed
2024-03-07T02:00:07
2024-03-08T22:46:36
2024-03-08T22:46:31
https://github.com/pandas-dev/pandas/pull/57755
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57755
https://github.com/pandas-dev/pandas/pull/57755
mroeschke
0
Enforces #43485 Optimization found in #57441
[ "Performance", "Clean", "Index" ]
0
0
0
0
0
0
0
0
[]
2,172,784,612
57,754
DEPR: make_block
closed
2024-03-07T01:55:30
2024-06-04T16:59:53
2024-06-04T16:44:18
https://github.com/pandas-dev/pandas/pull/57754
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57754
https://github.com/pandas-dev/pandas/pull/57754
jbrockmendel
5
- [x] closes #56815 (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. - [x] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Internals", "Deprecate" ]
0
0
0
0
0
0
0
0
[ "I have been working on a branch for pyarrow testing an alternative `to_pandas` implementation. I will try to finish that this week (that should then also be in time for including it in pyarrow 16.0), and then I will be able to give more concrete feedback here.", "BTW I posted some comments on the issue last week: https://github.com/pandas-dev/pandas/issues/56815", "@jorisvandenbossche with #58197 in are we good to move forward here?", "If there are no comments I plan to merge next week", "Updated, I think addressing all comments" ]
2,172,500,658
57,753
DOC: Incorrect Description For pd.concat sort Argument
closed
2024-03-06T21:54:40
2024-03-08T17:52:33
2024-03-08T17:52:33
https://github.com/pandas-dev/pandas/issues/57753
true
null
null
Wikilicious
4
### 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/reference/api/pandas.concat.html#pandas.concat ### Documentation problem The first part of the documentation for the `sort` argument in `pd.concat` is confusing and incorrect. ``` Sort non-concatenation axis if it is not already aligned. ``` It wasn't clear to me if the result `df` would be sorted if the `df`'s being concatenated were already aligned (but not sorted). I had to manually confirm. I suspect the wording originated from this bug #4588 Which added `FutureWarning: Sorting because non-concatenation axis is not aligned. A future version of pandas will change to not sort by default.` ### Suggested fix for documentation Remove the `if it is not already aligned` part.
[ "Docs", "Reshaping" ]
0
0
0
0
0
0
0
0
[ "Related: #57335 ", "Thanks for the report; confirmed alignment does not impact the result on main. Would you be interesting in submitting a PR to fix the docs @Wikilicious?\r\n\r\n```\r\nindex = pd.Index([\"a\", \"c\", \"b\"])\r\ndf = pd.DataFrame({\"a\": [1, 1, 2], \"b\": [3, 4, 5]}, index=index)\r\nser = pd.Series([6, 7, 8], index=index)\r\nprint(pd.concat([df, ser], axis=1, sort=True))\r\n# a b 0\r\n# a 1 3 6\r\n# b 2 5 8\r\n# c 1 4 7\r\n```", "Hi @rhshadrach \r\nYes, I'm interested in submitting a PR with the suggested fix.", "take" ]
2,172,299,366
57,752
PERF: RangeIndex.take/reindex/join with single/no value returns RangeIndex
closed
2024-03-06T19:46:51
2024-03-13T00:09:55
2024-03-13T00:09:52
https://github.com/pandas-dev/pandas/pull/57752
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57752
https://github.com/pandas-dev/pandas/pull/57752
mroeschke
1
Discovered in https://github.com/pandas-dev/pandas/pull/57441
[ "Performance", "Index" ]
0
0
0
0
0
0
0
0
[ "Closed via https://github.com/pandas-dev/pandas/pull/57770" ]
2,172,082,442
57,751
DOC: fixing GL08 errors for pandas.Series.dt
closed
2024-03-06T17:40:16
2024-03-17T08:13:18
2024-03-17T00:36:47
https://github.com/pandas-dev/pandas/pull/57751
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57751
https://github.com/pandas-dev/pandas/pull/57751
s1099
5
Resolved GL08 error for `scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.Series.dt` xref: #57443 - [ ] [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" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix", "I'm missing something. `Series.dt` seems to already have a docstring: https://pandas.pydata.org/docs/reference/api/pandas.Series.dt.html#pandas-series-dt\r\n\r\nYou seem to be modifying the one for Index. It would be good to use the `Series.dt` as reference, the `Parameters` and `Returns` section don't make sense to me for an accessor.", "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57751/", "Thanks @s1099 " ]
2,172,010,198
57,750
BUG: .loc operation cannot locate existing index when having single string as index for dataframe ('string',)
open
2024-03-06T16:59:06
2024-03-27T03:12:59
null
https://github.com/pandas-dev/pandas/issues/57750
true
null
null
carlonlv
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 temp = pd.DataFrame({'a': [1,2,3], 'b': False}, index=[('h',), ('v',), ('c',)]) print(('h',) in temp.index) ## This would print True temp.loc[('h',), 'b'] = True ## This would result in key error ``` ### Issue Description It seems like when having indices looking at ('a',), pandas automatically converts it into string 'a'. KeyError: "None of [Index(['h'], dtype='object')] are in the [index]" ### Expected Behavior temp.loc[('h',)] operation should be successful ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.5.final.0 python-bits : 64 OS : Linux OS-release : 6.5.0-1015-azure Version : #15~22.04.1-Ubuntu SMP Tue Feb 13 01:15:12 UTC 2024 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.1 numpy : 1.26.3 pytz : 2023.3.post1 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 : 3.1.3 IPython : 8.20.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : 1.3.7 dataframe-api-compat : None fastparquet : None fsspec : 2023.12.2 gcsfs : None matplotlib : 3.8.3 numba : None numexpr : 2.8.7 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 : 0.19.0 tzdata : 2023.3 qtpy : None pyqt5 : None </details>
[ "Bug", "Indexing", "Needs Discussion" ]
0
0
0
0
0
0
0
0
[ "Note that the same operation with tuples with length >= 2 works as expected.\r\n\r\nAlso in the above example, if I do temp.loc[temp.index == ('h',), 'b'] = True, it also works fine", "Please have a look at the following answer on StackOverflow; (it's an old one but still relevant)\r\nhttps://stackoverflow.com/questions/40186361/pandas-dataframe-with-tuple-of-strings-as-index\r\n\r\nIt will work if you pass the tuple inside a list as argument to the loc function (explanation in the link)\r\n`temp.loc[('h',), 'b'] = True` # error\r\nto\r\n`temp.loc[[('h',)], 'b'] = True` # works fine\r\n\r\nHope this helps !", "Thanks for the clarification. I was simply using the dataframe as dictionary. I guess this is one of the \"gotcha\" moment.", "Thanks for the report. pandas uses tuples to signify values in a MultiIndex, and this is the reason why your lookup fails. One idea is to treat non-MulitIndexes differently here, allowing for lookups with tuples, whereas supplying tuples when the index is a MultiIndex would interpret them as levels. Perhaps this has some bad implications though, further investigations are welcome!" ]
2,171,388,786
57,749
BUG: `Timestamp.unit` should reflect changes in components after `Timestamp.replace`
open
2024-03-06T12:26:27
2025-08-17T02:21:03
null
https://github.com/pandas-dev/pandas/issues/57749
true
null
null
wjsi
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 datetime import pandas as pd ts = pd.Timestamp("2023-07-15 23:08:12.134567123") print(ts) # shows Timestamp('2023-07-16 23:08:12.134567123') ts2 = pd.Timestamp(datetime.datetime.utcfromtimestamp(int(ts.timestamp()))) ts2 = ts2.replace(microsecond=ts.microsecond, nanosecond=ts.nanosecond) print(ts2) # shows Timestamp('2023-07-16 23:08:12.134567123') assert ts == ts2 # fails ``` ### Issue Description While repr(ts) and repr(ts2) are equal, direct comparison fails. ### Expected Behavior ts and ts2 shall be equal. ### Installed Versions INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 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 : None LANG : zh_CN.UTF-8 LOCALE : zh_CN.UTF-8 pandas : 2.2.1 numpy : 1.25.2 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 61.2.0 pip : 22.3.1 Cython : 3.0.2 pytest : 8.0.2 hypothesis : 6.46.5 sphinx : 7.2.6 blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : 8.1.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : 1.3.8 dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.7.2 numba : None numexpr : 2.8.4 odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : 11.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.11.1 sqlalchemy : 2.0.19 tables : None tabulate : None xarray : None xlrd : None zstandard : 0.21.0 tzdata : 2023.3 qtpy : None pyqt5 : None
[ "Bug", "Non-Nano", "Timestamp" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. This is due to the `unit` attributes not matching\r\n\r\n```python\r\nIn [4]: ts.unit\r\nOut[4]: 'ns'\r\n\r\nIn [5]: ts2.unit\r\nOut[5]: 'us'\r\n```\r\n\r\nHowever, I suppose the `unit` should probably reflect changes when `.replace` is used.", "take" ]
2,171,181,760
57,748
ENH: No longer always show hour, minute and second components for pd.Interval
open
2024-03-06T10:39:28
2025-08-17T02:21:21
null
https://github.com/pandas-dev/pandas/issues/57748
true
null
null
ClaireDons
2
### Feature Type - [ ] Adding new functionality to pandas - [X] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description `pd.Interval` behaviour change from #55035 means that hour, minute and second components is always shown regardless of if timezone is included as an argument. The default behaviour until now has been for time to be dropped if 00:00:00. In our use-case this broke some tests and does not provide useful information. ``` - anchor_year i_interval interval data is_target -0 2019 -1 [2019-07-04, 2019-12-31) 14.5 False -1 2019 1 [2019-12-31, 2020-06-28) 119.5 True -2 2020 -1 [2020-07-04, 2020-12-31) 305.5 False -3 2020 1 [2020-12-31, 2021-06-29) 485.5 True + anchor_year i_interval interval data is_target +0 2019 -1 [2019-07-04 00:00:00, 2019-12-31 00:00:00) 14.5 False +1 2019 1 [2019-12-31 00:00:00, 2020-06-28 00:00:00) 119.5 True +2 2020 -1 [2020-07-04 00:00:00, 2020-12-31 00:00:00) 305.5 False +3 2020 1 [2020-12-31 00:00:00, 2021-06-29 00:00:00) 485.5 True ``` ### Feature Description It would be nice to revert to dropping hour, minute and second components when 00:00:00 and when no timezone is specified. ### Alternative Solutions N/A ### Additional Context _No response_
[ "Bug", "Output-Formatting", "Regression", "Interval" ]
1
0
0
0
0
0
0
0
[ "To add to this: @ClaireDons is advocating for reverting to the previous behavior (pre-2.2.0).\r\n\r\nIn cases where only dates matter and all the data is timezone naive, adding the hours, minutes and seconds to the `__repr__` of the `pd.Timestamp` adds a lot of visual clutter.\r\n\r\nThis change was not warned for, nor discussed or reviewed in #55035 and #55015, but came as a byproduct of showing the timezone offset.", "cc @mroeschke " ]
2,170,931,074
57,747
CI: only keep conda cache for one day
closed
2024-03-06T08:35:21
2024-08-21T08:04:00
2024-05-22T17:34:28
https://github.com/pandas-dev/pandas/pull/57747
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57747
https://github.com/pandas-dev/pandas/pull/57747
jorisvandenbossche
3
Our conda envs are being cached, but that also means that for the dev builds (eg numpy nightly, pyarrow nightly), you don't actually get the latest version, depending on whether some other change happened in the CI setup that would invalidate the cache. Maybe ideally we do this _only_ for those builds that test for other dev packages? From https://github.com/mamba-org/setup-micromamba?tab=readme-ov-file#caching Related issue: https://github.com/mamba-org/setup-micromamba/issues/50
[ "CI", "Stale" ]
0
0
0
0
0
0
0
0
[ "I would also support invalidating all caches daily (the pre-commit caches I think are the only ones that are not affected by changing the conda key). You could update this workflow's cron to daily (and rename the file) https://github.com/pandas-dev/pandas/blob/main/.github/workflows/cache-cleanup-weekly.yml ", "This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.", "This got implemented in https://github.com/pandas-dev/pandas/pull/58710 (thanks for the inspiration!) so closing" ]
2,170,590,457
57,746
CLN: Enforce deprecation of groupby.idxmin/idxmax with skipna=False not raising
closed
2024-03-06T04:01:24
2024-03-06T23:59:05
2024-03-06T23:58:10
https://github.com/pandas-dev/pandas/pull/57746
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57746
https://github.com/pandas-dev/pandas/pull/57746
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: #54234 In the original deprecation, I missed the case of all NA values. Opened https://github.com/pandas-dev/pandas/issues/57745 to track.
[ "Groupby", "Missing-data", "Clean", "Reduction Operations" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,170,582,313
57,745
BUG: groupby.idxmin/idxmax will all NA values
closed
2024-03-06T03:50:28
2025-08-05T18:55:44
2025-08-05T18:55:44
https://github.com/pandas-dev/pandas/issues/57745
true
null
null
rhshadrach
4
#54234 deprecated the case of `skipna=False` and any NA value, but for consistency with Series/DataFrame versions, we also want the case of `skipna=True` with all NA values in a group to also raise. E.g. this should raise a ValueError ``` df = pd.DataFrame({'a': [1, 1, 2], 'b': np.nan}) gb = df.groupby("a") print(gb.idxmin()) ```
[ "Groupby", "Missing-data", "Deprecate", "Reduction Operations" ]
0
0
0
0
0
0
0
0
[ "Make this a breaking change in 3.0? Could do a full deprecation cycle, but the inconsistency will be annoying in the interim.", "That sounds good to me.", "Did we ever do this?", "I don't believe so; I'll take a look into implementing it." ]
2,170,550,707
57,744
CLN: Enforce deprecation of groupby.quantile supporting bool dtype
closed
2024-03-06T03:28:08
2024-03-07T02:16:13
2024-03-07T00:02:39
https://github.com/pandas-dev/pandas/pull/57744
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57744
https://github.com/pandas-dev/pandas/pull/57744
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: #53975
[ "Groupby", "Clean", "quantile" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,170,524,253
57,743
CLN: Enforce deprecation get_group with tuples of length 1
closed
2024-03-06T02:55:35
2024-03-07T21:08:57
2024-03-07T04:42:40
https://github.com/pandas-dev/pandas/pull/57743
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57743
https://github.com/pandas-dev/pandas/pull/57743
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: #54155 & #50064
[ "Groupby", "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,170,509,369
57,742
CLN: Enforce deprecation of method and limit in pct_change methods
closed
2024-03-06T02:37:11
2024-03-07T00:00:16
2024-03-06T23:59:42
https://github.com/pandas-dev/pandas/pull/57742
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57742
https://github.com/pandas-dev/pandas/pull/57742
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: #53520
[ "Missing-data", "Clean", "Transformations" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,170,478,510
57,741
CLN: Enforce deprecation of groupby with as_index=False excluding out-of-axis groupings
closed
2024-03-06T02:03:31
2024-03-07T02:16:18
2024-03-07T00:01:46
https://github.com/pandas-dev/pandas/pull/57741
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57741
https://github.com/pandas-dev/pandas/pull/57741
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: #49519
[ "Groupby", "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,170,214,875
57,740
Backport PR #57172: MAINT: Adjust the codebase to the new 's keyword meaning
closed
2024-03-05T22:00:43
2024-03-06T00:08:21
2024-03-06T00:08:18
https://github.com/pandas-dev/pandas/pull/57740
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57740
https://github.com/pandas-dev/pandas/pull/57740
mroeschke
0
null
[ "Compat" ]
0
0
0
0
0
0
0
0
[]
2,170,200,544
57,739
COMPAT: Utilize `copy` keyword in `__array__`
closed
2024-03-05T21:49:15
2024-11-04T20:19:57
2024-11-04T20:19:57
https://github.com/pandas-dev/pandas/issues/57739
true
null
null
mroeschke
9
https://github.com/pandas-dev/pandas/pull/57172 add a copy keyword that will be passed in with `__array__` in Numpy 2.0. Currently it is unused but it would be useful to respect that option when passed
[ "Compat" ]
1
0
0
0
0
1
0
0
[ "Linking the numpy issue I opened to discuss the expected semantics for this: https://github.com/numpy/numpy/issues/25941 (in several places we now also ignore the `dtype` keyword, but for `copy` that's something we shouldn't do)", "I believe this came up again in a new issue. Should this be a blocker for 3.0?", "IMO I don't think this \"bug\" should block a release, but would be very nice to fix for 3.0", "Hi - this is caused fairly large blocking issues in a production environment for us. If there was a way to roll a fix out , that would be great...\r\n", "This is a very simple thing to hot-fix @mg3146 you could probably do a PR yourself even. I agree it is a relatively large issue (because it can lead to silently modified dataframes on existing code).\r\nMaking a defensive copy may not be always ideal, but is totally fine. Only `copy is False` might be tricky, but `copy=False` is a new feature, so hopefully not a big deal in practice.\r\n\r\nIf you can't (or do not want) guess `copy=False` correctly, I think it is fine to just reject it always. That might be a small argument for fixing it in 3.0: avoid breaking code that thinks `copy=False` work when you turn it into an error.", "This bug is affecting statsmodels. Internally we mostly use ndarrays for predictability, and then wrap results as needed for pandas inputs. To do this, we often call `np.array(list | DataFrame | Series | nparray, copy=True)` when it is efficient that we own a copy of the data, e.g, when needing to sort. Since pandas does not return a copy, we end up modifying the original data, which is highly undesirable.\r\n", "> This is a very simple thing to hot-fix @mg3146 you could probably do a PR yourself even. I agree it is a relatively large issue (because it can lead to silently modified dataframes on existing code). Making a defensive copy may not be always ideal, but is totally fine. Only `copy is False` might be tricky, but `copy=False` is a new feature, so hopefully not a big deal in practice.\r\n> \r\n> If you can't (or do not want) guess `copy=False` correctly, I think it is fine to just reject it always. That might be a small argument for fixing it in 3.0: avoid breaking code that thinks `copy=False` work when you turn it into an error.\r\n\r\nsorry - I honestly dont know what half this means... ", "[This bug is affecting matplotlib code.](https://github.com/matplotlib/matplotlib/issues/29002) Computing a colormap on a Series object has the unexpected behavior that the Series object gets modified. ", "We will include a fix for this in pandas 2.3 (which is targetted for in 2-3 weeks)" ]
2,169,952,694
57,738
BUG: Convertion fails for columns with datetime64[ms]
open
2024-03-05T18:59:14
2025-03-07T21:22:15
null
https://github.com/pandas-dev/pandas/issues/57738
true
null
null
alvarofagner
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. - [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 if __name__ == "__main__": df = pd.DataFrame( [ ["2023-09-29 02:55:54"], ["2023-09-29 02:56:03"], ], columns=["timestamp"], dtype="datetime64[ms]", ) serialized = df.to_json() print(serialized) # Got: {"timestamp":{"0":1695956,"1":1695956}} # Should be: {"timestamp":{"0":1695956154000,"1":1695956163000}} deserialized = pd.read_json(serialized, convert_dates=["timestamp"]) print(pd.to_datetime(deserialized["timestamp"], unit="ms")) # Got: # 0 1970-01-01 00:28:15.956 # 1 1970-01-01 00:28:15.956 # Instead of: # 0 2023-09-29 02:55:54 # 1 2023-09-29 02:56:03 ``` ### Issue Description When a dataframe contains a column which dtype is `datetime64[ms]` and one tries to convert it to json using `df.to_json()` the data does not correspond to the correct value. So trying to convert it back will give the default timestamp. See example. ### Expected Behavior The json values for the timestamp should be the correspoinding one for the given date string so it we can restore the correct date/time. It works when using datetime64[ns]. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.12.1.final.0 python-bits : 64 OS : Linux OS-release : 5.4.0-150-generic Version : #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 machine : x86_64 processor : byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.1 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.1.1 pip : 23.3.1 Cython : None pytest : 8.0.2 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 : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : 2.0.27 tables : None tabulate : None xarray : None xlrd : None zstandard : 0.22.0 tzdata : 2024.1 qtpy : None pyqt5 : None None </details>
[ "Bug", "IO JSON", "Non-Nano" ]
0
0
0
0
0
0
0
0
[ "xref #55827 ", "I encountered this same problem with the to_datetime64() function when upgrading to version 2.2\r\n\r\nAccording to the documentation, until version 2.0.3 the pandas.Timestamp.to_datetime64 function returned \"a numpy.datetime64 object with 'ns' precision\". Since version 2.1.4 that function returns \"a numpy.datetime64 object with same precision\".\r\n\r\nThis change has broken critical parts of my code that assumed conversion with nanosecond precision, and now depending on the decimals of the argument passed the behavior of the function is unpredictable.\r\n\r\nI recommend downgrading to an older version of pandas to resolve it.", "If you specify ``date_format=\"iso\"`` in the ``to_json`` call, the round-tripping happens successfully. \r\n\r\n(Note: the dtype will still be ``datetime64[ns]``, though for stuff in range for datetime64ns. I don't know if we should be reading stuff that's in-bounds for datetime64[ns] as non-nano)\r\n\r\nIt looks like we can do better with preserving a dtype for non-nano datetimes, though.\r\n\r\nRunning\r\n```\r\nimport pandas as pd\r\n\r\nif __name__ == \"__main__\":\r\n df = pd.DataFrame(\r\n [\r\n [\"1000-09-29 02:55:54\"],\r\n [\"1000-09-29 02:56:03\"],\r\n ],\r\n columns=[\"timestamp\"],\r\n dtype=\"datetime64[ms]\",\r\n )\r\n import io\r\n serialized = df.to_json(date_format=\"iso\")\r\n print(serialized)\r\n deserialized = pd.read_json(io.StringIO(serialized), convert_dates=[\"timestamp\"])\r\n print(deserialized)\r\n print(deserialized.dtypes)\r\n```\r\n\r\nI get object dtype for the deserialized json timestamp column\r\n\r\nOutput\r\n```\r\n{\"timestamp\":{\"0\":\"1000-09-29T02:55:54.000\",\"1\":\"1000-09-29T02:56:03.000\"}}\r\n timestamp\r\n0 1000-09-29T02:55:54.000\r\n1 1000-09-29T02:56:03.000\r\ntimestamp object\r\ndtype: object\r\n```\r\n\r\n", "Adding `date_unit='ns'` to `to_json` call makes serialization work properly, even if the index or column type still `datetime64[ms]`" ]
2,169,859,389
57,737
CI/TST: Use worksteal over loadfile for pytest-xdist
closed
2024-03-05T18:12:48
2024-03-26T20:35:03
2024-03-26T20:35:01
https://github.com/pandas-dev/pandas/pull/57737
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57737
https://github.com/pandas-dev/pandas/pull/57737
mroeschke
2
In theory, this should help alleviate a worker that is running tests from a larger file. Let's see if it saves any time on the CI.
[ "CI" ]
0
0
0
0
0
0
0
0
[ "I'm seeing about a ~5-7 minute test run reduction on Ubuntu/Windows jobs and ~10-15 minute test run reduction on OSX jobs. ", "Going to merge since all green here" ]
2,169,745,272
57,736
ENH: Assign for pandas Series
closed
2024-03-05T17:10:42
2024-03-16T14:18:24
2024-03-16T14:18:24
https://github.com/pandas-dev/pandas/issues/57736
true
null
null
cbrummitt
4
### Feature Type - [X] Adding new functionality to pandas - [ ] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description I frequently use [`pd.DataFrame.assign`](https://github.com/pandas-dev/pandas/blob/v2.2.1/pandas/core/frame.py#L5161-L5227) in chains of statements, following the pattern in the blog post [Method Chaining](https://tomaugspurger.net/posts/method-chaining/) in Tom Augspurgers's series Modern Pandas. For example: ```python df.assign(x=lambda df: df['y'] + 1).groupby('x').agg(['sum', 'mean']) ``` I wish there were an equivalent for Series. ### Feature Description A new method on pandas Series would, given keyword arguments, assign them as rows, and return a pointer to itself (to enable chaining of statements). The implementation could look like this: ```python def assign(**kwargs) -> Series: new_ser = self.copy(deep=False) for k, v in kwargs.items(): new_ser.__set_item__(k, v) return new_ser ``` ### Alternative Solutions An alternative is to do nothing, and users continue to break up statements into multiple statements. For example, rather than ```python summary = series.assign(grand_total=lambda s: s.sum()).to_string() ``` the user breaks it up as: ```python series.loc['grand_total'] = series.sum() summary = series.to_string() ``` This simple example makes the alternative look not so bad, but when you have chains of multiple method calls involving one or more `assign` statements, when you use Series you have to break it up, while with DataFrames you can chain them all. ### Additional Context I [searched issues for "series assign"](https://github.com/pandas-dev/pandas/issues?q=is%3Aissue+is%3Aopen+series+assign) and didn't find an issue that duplicates this one. Something that may confuse readers is that DataFrame.assign makes new columns, while the proposed Series.assign makes new rows (provided that you think of Series as column vectors, which is natural since that's how they're displayed, they have an index, and that's what you get when you call `.to_frame()`).
[ "Enhancement", "Reshaping", "Needs Discussion", "Series", "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "Thanks for the request. `Series.assign` would have to make a copy of the entire Series, whereas `DataFrame.assign` does not (now with Copy On Write). In general, expanding Series / DataFrame rows is something that should be avoided whenever possible for performance, and I think making this easier to do would encourage bad practices. For this reason, I'm currently opposed.", "Got it. Is there a way to implement it like [`dict.update`](https://docs.python.org/3/library/stdtypes.html#dict.update) that would make it perform quickly?", "No, the memory layout prevents doing this efficiently", "closing" ]
2,169,491,951
57,735
BUG: ValueError with loc[] = (Regression 2.1.0)
closed
2024-03-05T15:14:01
2024-07-29T19:42:56
2024-07-29T19:42:56
https://github.com/pandas-dev/pandas/issues/57735
true
null
null
rxxg
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 df = pd.DataFrame(index=[1, 1, 2, 2], data=["1", "1", "2", "2"]) df.loc[df[0].str.len() > 1, 0] = df[0] df ``` ### Issue Description Given code fails on the third line with exception given below Code executes normally with panda versions <2.1.0 Traceback (most recent call last): File "<input>", line 3, in <module> File "C:\Users\venv\lib\site-packages\pandas\core\indexing.py", line 885, in __setitem__ iloc._setitem_with_indexer(indexer, value, self.name) File "C:\Users\venv\lib\site-packages\pandas\core\indexing.py", line 1888, in _setitem_with_indexer indexer, value = self._maybe_mask_setitem_value(indexer, value) File "C:\Users\venv\lib\site-packages\pandas\core\indexing.py", line 789, in _maybe_mask_setitem_value value = self.obj.iloc._align_series(indexer, value) File "C:\Users\venv\lib\site-packages\pandas\core\indexing.py", line 2340, in _align_series return ser.reindex(new_ix)._values File "C:\Users\venv\lib\site-packages\pandas\core\series.py", line 4982, in reindex return super().reindex( File "C:\Users\venv\lib\site-packages\pandas\core\generic.py", line 5521, in reindex return self._reindex_axes( File "C:\Users\venv\lib\site-packages\pandas\core\generic.py", line 5544, in _reindex_axes new_index, indexer = ax.reindex( File "C:\Users\venv\lib\site-packages\pandas\core\indexes\base.py", line 4433, in reindex raise ValueError("cannot reindex on an axis with duplicate labels") ValueError: cannot reindex on an axis with duplicate labels ### Expected Behavior Code should execute normally with result 0 1 1 1 1 2 2 2 2 (No reindexing should be necessary since no rows are selected with code on line 3.) ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : ba1cccd19da778f0c3a7d6a885685da16a072870 python : 3.9.0.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19041 machine : AMD64 processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : English_Ireland.1252 pandas : 2.1.0 numpy : 1.24.2 pytz : 2023.3 dateutil : 2.8.2 setuptools : 65.5.1 pip : 22.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 bs4 : None bottleneck : None dataframe-api-compat: None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.3 qtpy : None pyqt5 : None </details>
[ "Bug", "Indexing" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report!\r\n\r\n> (No reindexing should be necessary since no rows are selected with code on line 3.)\r\n\r\nTo be sure, it's not the left hand side that is reindexing, it's the right. E.g.\r\n\r\n df.loc[df[0].str.len() > 1, 0] = 5\r\n\r\nworks. I believe we raise anytime the RHS has a duplicate value because the result _can be_ ambiguous, even though it won't necessarily be ambiguous. In general we try to avoid values-dependent behavior. In this case, if it just so happens that in one case the mask on the left is all False you may think the code works, but will then fail as soon as it isn't all False. That can be a bad user experience.", "> Code executes normally with panda versions <2.1.0\r\n\r\nAh, I missed this! Thanks for that detail. We should run a git blame and see where this ended up getting changed.", "take", "take" ]
2,169,350,158
57,734
QST: How to solve pandas (2.2.0) "FutureWarning: Downcasting behavior in `replace` is deprecated" on a Series?
closed
2024-03-05T14:17:44
2025-08-13T08:58:05
2024-03-06T21:55:47
https://github.com/pandas-dev/pandas/issues/57734
true
null
null
buhtz
22
### Research - [X] I have searched the [[pandas] tag](https://stackoverflow.com/questions/tagged/pandas) on StackOverflow for similar questions. - [X] I have asked my usage related question on [StackOverflow](https://stackoverflow.com). ### Link to question on StackOverflow https://stackoverflow.com/q/77995105/4865723 ### Question about pandas Hello, and please take my apologize for asking this way. My stackoverflow question [1] was closed for IMHO no good reason. The linked duplicates do not help me [2]. And I was also asking on pydata mailing list [3] without response. The example code below gives me this error using Pandas 2.2.0 FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)` s = s.replace(replace_dict) I found several postings about this future warning. But my problem is I don't understand why it happens and I also don't know how to solve it. ``` #!/usr/bin/python3 from pandas import Series s = Series(['foo', 'bar']) replace_dict = {'foo': 2, 'bar': 4} s = s.replace(replace_dict) ``` I am aware of other questions and answers [2] but I don't know how to apply them to my own code. The reason might be that I do not understand the cause of the error. The linked answers using `astype()` before replacement. But again: I don't know how this could solve my problem. Thanks in advance Christian [1] -- <https://stackoverflow.com/q/77995105/4865723> [2] -- <https://stackoverflow.com/q/77900971/4865723> [3] -- <https://groups.google.com/g/pydata/c/yWbl4zKEqSE>
[ "Docs", "Usage Question" ]
4
0
0
0
0
0
0
0
[ "Just do\r\n\r\n```\r\npandas.set_option(\"future.no_silent_downcasting\", True)\r\n```\r\n\r\nas suggested on the stack overflow question\r\n\r\nThe series will retain object dtype in pandas 3.0 instead of casting to int64", "> ```\r\n> pandas.set_option(\"future.no_silent_downcasting\", True)\r\n> ```\r\n\r\nBut doesn't this just deactivate the message but doesn't modify the behavior.\r\n\r\nTo my understanding the behavior is the problem and need to get solved. Or not?\r\nMy intention is to extinguish the fire and not just turn off the fire alarm but let the house burn down.", "I'm having this problem as well. I have the feeling it's related to `.replace` changing the types of the values (as one Stack Overflow commenter [implied](https://stackoverflow.com/questions/77900971/pandas-futurewarning-downcasting-object-dtype-arrays-on-fillna-ffill-bfill#comment137615068_77941616)). Altering the original example slightly:\r\n\r\n```python\r\ns = Series(['foo', 'bar'])\r\nreplace_dict = {'foo': '1', 'bar': '2'} # replacements maintain original types\r\ns = s.replace(replace_dict)\r\n```\r\n\r\nmakes the warning go away. \r\n\r\nI agree with @buhtz in that setting the \"future\" option isn't really getting at the root of understanding how to make this right. I think the hard part for most of us who have relied on `.replace` is that we never thought of it as doing any casting -- it was replacing. Now the semantics seem to have changed. It'd be great to reopen this issue to clarify the thinking, intention, and direction so that we can come up with appropriate work-arounds.", "> s that we never thought of it as doing any casting\r\n\r\nThis is exactly the thing we are trying to solve. replace was previously casting your dtypes and will stop doing so in pandas 3", "> This is exactly the thing we are trying to solve. replace was previously casting your dtypes and will stop doing so in pandas 3\r\n\r\nBut it is unclear how to replace and cast. E.g. when I have `[0, 1]` integers they stand for female and male.\r\n\r\n```\r\ndf.gender = df.gender.astype(str)\r\ndf.gender = df.gender.replace({'0': 'male', '1': 'female'})\r\n```\r\n\r\nIs that the solution you have in mind? From a users perspective it is a smelling workaround.\r\n\r\nThe other way around is nearly not possible because I can not cast a str word to an integer.\r\n\r\n```\r\nprint(df.gender) # ['male', 'male', 'female']\r\ndf.gender = df.gender.astype(int) # <-- ERROR\r\ndf.gender = df.gender.replace({'male': 0, 'female': 1})\r\n```\r\n\r\nWhat is wrong with casting in replace() ?", "> The other way around is nearly not possible because I can not cast a str word to an integer.\r\n\r\nOne alternative (although I realise a non `.replace` supported \"alternative\" may not be what was actually desired) is to use categoricals with `.assign`:\r\n\r\n```python\r\nimport pandas as pd\r\n\r\ndf = pd.DataFrame(['male', 'male', 'female'], columns=['gender']) # from the original example\r\ngenders = pd.Categorical(df['gender'])\r\ndf = df.assign(gender=genders.codes)\r\n```\r\n\r\nIf semantically similar data is spread across multiple columns, it gets a little more involved:\r\n\r\n```python\r\nimport random\r\nimport numpy as np\r\nimport pandas as pd\r\n\r\ndef create_data(columns):\r\n genders = ['male', 'male', 'female']\r\n for i in columns:\r\n yield (i, genders.copy())\r\n random.shuffle(genders)\r\n\r\n# Create the dataframe\r\ncolumns = [ f'gender_{x}' for x in range(3) ]\r\ndf = pd.DataFrame(dict(create_data(columns)))\r\n\r\n# Incorporate all relevant data into the categorical\r\nview = (df\r\n .filter(items=columns)\r\n\t.unstack())\r\ncategories = pd.Categorical(view)\r\nvalues = np.hsplit(categories.codes, len(columns))\r\nto_replace = dict(zip(columns, values))\r\n\r\ndf = df.assign(**to_replace)\r\n```\r\nwhich I think is what the Categorical [documentation](https://pandas.pydata.org/pandas-docs/stable/user_guide/categorical.html#controlling-behavior) is trying to imply.", "I got here, trying to understand what `pd.set_option('future.no_silent_downcasting', True)` does.\r\n\r\nThe message I get is from `.fillna()`, which is the same message for `.ffill()` and `.bfill()`. So I'm posting this here in case someone is looking for the same answer using the mentioned functions. This is the warning message I get:\r\n```\r\nFutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version.\r\nCall result.infer_objects(copy=False) instead.\r\nTo opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`\r\n```\r\n\r\nMaybe the confusion arises from the way the message is phrased, I believe it's kind of confusing, it creates more questions than answers:\r\n- Do I need to do some downcasting?\r\n- Am I doing some downcasting somewhere where I am not aware?\r\n- When the messages stated `Call result.infer_objects(copy=False) instead.`, is it telling me to call it before the function I'm trying to use, after? Is it telling me not to use the function? (I guess not since `infer_objects` should do something different than `replace` or one of the `fill` functions)\r\n- By using `pd.set_option('future.no_silent_downcasting', True)` am I removing the downcasting or am I making the downcasting not silent? Maybe both?\r\n\r\nFrom what I understand, `pd.set_option('future.no_silent_downcasting', True)` removes the downcasting the functions do and if it needs to do some downcasting an error would be raised, but I would need to be corrected here if I'm wrong.", "So... I did some digging and I think I have a better grasp of what's going on with this FutureWarning. So I wrote an article in Medium to explain what's happening. If you want to give it a read, here it is:\r\n\r\n[Deciphering the cryptic FutureWarning for .fillna in Pandas 2](https://medium.com/@felipecaballero/deciphering-the-cryptic-futurewarning-for-fillna-in-pandas-2-01deb4e411a1)\r\n\r\nLong story short, do:\r\n```python\r\nwith pd.option_context('future.no_silent_downcasting', True):\r\n # Do you thing with fillna, ffill, bfill, replace... and possible use infer_objects if needed\r\n```", "I feel like this thread is starting to become a resource. In that spirit:\r\n\r\nI just experienced another case where `.replace` would have been amazing, but I now need an alternative: a column of strings that are meant to be floats, where the only \"offending\" values are empty strings (meant to be NaN's). Consider:\r\n\r\n```python\r\nrecords = [\r\n {'a': ''},\r\n {'a': 12.3},\r\n]\r\ndf = pd.DataFrame.from_records(records)\r\n```\r\n\r\nI would have first reached for `.replace`. Now I consider `.filla`, but that doesn't work either. Using `.assign` with `.to_numeric` does the trick:\r\n\r\n```python\r\nIn [1]: df.dtypes\r\nOut[1]: \r\na object\r\ndtype: object\r\n\r\nIn [2]: x = df.assign(a=lambda x: pd.to_numeric(x['a']))\r\n\r\nIn [3]: x\r\nOut[3]: \r\n a\r\n0 NaN\r\n1 12.3\r\n\r\nIn [4]: x.dtypes\r\nOut[4]: \r\na float64\r\ndtype: object\r\n```", "From your code:\r\n> ```python\r\n> x = df.assign(a=lambda x: pd.to_numeric(x['a']))\r\n> ```\r\nI would do it like this, it feels a little cleaner and easier to read:\r\n```python\r\ndf['a'] = pd.to_numeric(df['a'])\r\n```\r\n\r\n---\r\n\r\nYou said you wanted to use `replace`, if you want to use it, you can do this:\r\n```python\r\nwith pd.option_context('future.no_silent_downcasting', True):\r\n df2 = (df\r\n .replace('', float('nan')) # Replace empty string for nans\r\n .infer_objects() # Allow pandas to try to \"infer better dtypes\"\r\n )\r\n\r\ndf2.dtypes\r\n\r\n# a float64\r\n# dtype: object\r\n```\r\n\r\n---\r\n\r\nA note about \r\n\r\n> Now I consider `.filla`, but that doesn't work either.\r\n\r\nThat would not work because `.fillna` fills na values but `''` (empty string) is not na. (see [Filling missing data](https://pandas.pydata.org/pandas-docs/stable/user_guide/missing_data.html#filling-missing-data)).", "explicitly do the conversion in two steps and the future warning will go away.\r\n\r\nIn the first step, do the replace with the numbers as strings to match the original dtype\r\nreplace_dict = {'foo': '2', 'bar': '4'}\r\n\r\nin the second step, convert the dtype to int\r\ns = s.replace(replace_dict).astype(int)\r\n\r\nThis will run without the warning even when you have not suppressed warnings\r\n", "I got this because I was trying to filter a dataframe using the output from `Series.str.isnumeric()`.\r\nMy dataframe contained NA values, so the resulting mask contained NA values.\r\nNormally I use `fillna(False)` to get rid of these.\r\n\r\nWhat I would normally do:\r\n\r\n``` python\r\ndf = pd.DataFrame({'A': ['1', '2', 'test', pd.NA]})\r\nmask = df['A'].str.isnumeric().fillna(False)\r\n```\r\n\r\nWhat I need to do now:\r\n\r\n``` python\r\ndf = pd.DataFrame({'A': ['1', '2', 'test', pd.NA]})\r\nwith pd.option_context('future.no_silent_downcasting', True):\r\n mask = df['A'].str.isnumeric().fillna(False)\r\n```\r\n\r\nThe mask still seems to work without casting it to boolean.\r\n\r\nSee the [official deprecation notice](https://pandas.pydata.org/docs/whatsnew/v2.2.0.html#deprecated-automatic-downcasting) in the release notes.\r\n\r\nNote that if you don't mind either way, the original code still works, and will silently downcast the dtype (with a warning) until Pandas 3.0, then will switch to preserve the dtype after Pandas 3.0.", "It would be great if we could stop breaking changes. ", "Hello Folks,\r\nThanks for your helpful previous answers.\r\nEspecially \r\n\r\n> explicitly do the conversion in two steps and the future warning will go away.\r\n> \r\n> In the first step, do the replace with the numbers as strings to match the original dtype replace_dict = {'foo': '2', 'bar': '4'}\r\n> \r\n> in the second step, convert the dtype to int s = s.replace(replace_dict).astype(int)\r\n> \r\n> This will run without the warning even when you have not suppressed warnings\r\n\r\nThis works well when going trom string to int; but i struggle to go from string to bool : \r\n\r\n```\r\ndf=pd.DataFrame({'a':['','X','','X','X']})\r\n```\r\nI want to replace '' with False & 'X' with True\r\n\r\nTrying to go from string to bool directly\r\n```\r\nd_string= {'':'True','X':'False'}\r\ns = df['a'].replace(d_string)\r\nprint (s)\r\n0 True\r\n1 False\r\n2 True\r\n3 False\r\n4 False\r\nName: a, dtype: object\r\n\r\nprint(s.astype('bool')) # this doesn't work\r\n0 True\r\n1 True\r\n2 True\r\n3 True\r\n4 True\r\nName: a, dtype: bool\r\n```\r\ngoing from string to int to bool works; but isn't there a better solution ? i must be missing something obvious right ?\r\n```\r\nd_int = {'':'0','X':'1'}\r\ns = df['a'].replace(d_int)\r\nprint (s)\r\n0 0\r\n1 1\r\n2 0\r\n3 1\r\n4 1\r\nName: a, dtype: object\r\n\r\nprint(s.astype('int'))\r\n0 0\r\n1 1\r\n2 0\r\n3 1\r\n4 1\r\nName: a, dtype: int64\r\n\r\nprint(s.astype('int').astype('bool')) # --> this is the only solution i found using replace\r\n without triggering the downcasting warning\r\n0 False\r\n1 True\r\n2 False\r\n3 True\r\n4 True\r\nName: a, dtype: bool\r\n```\r\n", "Arnaudno,\r\n\r\nYou're doing more work than you need to. The boolean value of all strings except for empty strings is true (empty strings have a boolean value of false). So in your case, you don't need the replace at all. All you need is to convert the string to boolean and you will get the result you want.\r\n\r\ndf=pd.DataFrame({'a':['','X','','X','X']})\r\ns = df['a'].astype('bool')\r\nprint(s)\r\n\r\nand you will get\r\n\r\n0 False\r\n1 True\r\n2 False\r\n3 True\r\n4 True\r\nName: a, dtype: bool", "Thank you very much @Data-Salad .\r\n", "Instead of .replace you can also use .map", "Những chuyện này là sao. Nói hỗ trợ giúp đỡ. Nhưng làm văn bản. Công thức.\r\nKhông có lời dẫn hay thuyết minh. Rồi cuối cùng những thông tin vừa xong\r\nlãi vỡ ra. Lại bị thay đổi 1 lần nữa. 3 cái diện thoại giờ nó dùng k khác\r\ngì thập niên 80. Thông tin cá nhân giờ thể xác thực. Đến số điện thoại.\r\nHiện tại cũng không thể chứng minh nó là của mình. Nói không tin. Không hợp\r\ntác phối hợp. Vậy 1 tháng qua tôi trải qua những gì ai biết không???\r\n\r\nVào Th 7, 21 thg 12, 2024 lúc 17:08 herzphi ***@***.***> đã\r\nviết:\r\n\r\n> Instead of .replace you can also use .map\r\n>\r\n> —\r\n> Reply to this email directly, view it on GitHub\r\n> <https://github.com/pandas-dev/pandas/issues/57734#issuecomment-2558072432>,\r\n> or unsubscribe\r\n> <https://github.com/notifications/unsubscribe-auth/AKUN6KFMDA6CMZOAEQRIQ232GU4Z5AVCNFSM6AAAAABEHHIQSKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNJYGA3TENBTGI>\r\n> .\r\n> You are receiving this because you are subscribed to this thread.Message\r\n> ID: ***@***.***>\r\n>\r\n", "To sum up, to resolve this warning, values of the same type should be used and then they can be cast to e.g. `int`, like that:\r\n```python\r\nreplace_dict = {'foo': '2', 'bar': '4'} # keys are str and so must be values\r\ns = s.replace(replace_dict).astype(int) # cast values to int\r\n```", "This solution is not perfect for those of us what have empty rows in the column they are replacing (I have a column of occasional text labels which I was converting to int's for plotting purposes). \r\n\r\nIn this case `.astype(int)` can't cope with empty or nan, so `.astype(float)` is required.", "In my case, I had to convert strings to either bools or nan depending on the value of the string.\r\n\r\nInstead of suppressing the warning resulting from using replace(), I think it is generally better to use map() when you need to both change dtypes and deal with null values. Given:\r\n```\r\nprint(df['has_attribute'])\r\nName\r\nA Yes\r\nB No\r\nC Unknown\r\nName: has_attribute, Length: 3, dtype: object\r\n```\r\nI do:\r\n```\r\ndf = df.map(lambda x: True if x == 'Yes' else (False if x == 'No' else np.nan))\r\nprint(df['has_attribute'])\r\n```\r\nWhich, without any warnings, results in:\r\n```\r\nName\r\nA True\r\nB False\r\nC NaN\r\nName: has_attribute, Length: 3, dtype: object\r\n```", "> Just do\n> \n> ```\n> pandas.set_option(\"future.no_silent_downcasting\", True)\n> ```\n> \n> as suggested on the stack overflow question\n> \n> The series will retain object dtype in pandas 3.0 instead of casting to int64\n\nI've done it for now, just wonder when my pandas is upgraded to 3.0 next time, will there be any notification that I can remove this pd.set_option?" ]
2,168,736,610
57,733
PERF: improve StringArray.isna
open
2024-03-05T09:38:01
2025-07-08T17:02:06
null
https://github.com/pandas-dev/pandas/pull/57733
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57733
https://github.com/pandas-dev/pandas/pull/57733
jorisvandenbossche
2
See https://github.com/pandas-dev/pandas/issues/57431#issuecomment-1978293416 for context. - [ ] 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. Speed-up is around 2x for this case (extracted from one of our ASVs): ```python dtype = "string" N = 10**6 data = np.array([str(i) * 5 for i in range(N)], dtype=object) na_value = pd.NA ser = pd.Series(data, dtype=dtype) %timeit ser.isna() # 11.3 ms ± 47.4 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) <-- main # 5.01 ms ± 55.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) <-- PR ``` Not entirely sure it is worth the extra code, but so it definitely gives a decent speedup for a common operation.
[ "Performance", "Strings", "Stale" ]
0
0
0
0
0
0
0
0
[ "This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.", "needs rebase, otherwise LGTM" ]
2,168,579,280
57,732
DOC: fixing GL08 errors for pandas.IntervalIndex.right and pandas.Series.dt
closed
2024-03-05T08:13:49
2024-03-06T17:41:11
2024-03-05T19:02:38
https://github.com/pandas-dev/pandas/pull/57732
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57732
https://github.com/pandas-dev/pandas/pull/57732
s1099
3
Resolved GL08 errors for the following: 1. `scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.IntervalIndex.right` 2. `scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.Series.dt` xref: #57443 - [ ] [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" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix", "Also, since you worked on the `main` branch, you may want to clone pandas again and start the work in different branches. If you work in `main`, then any new branch you create to work in different things in parallel will contain the changes you made in `main`, and you will have unrelated things in the branches. In general you want to make sure you never commit to `main` and it's synced with the latest `main` in pandas, so when you create branches you start from the right state of pandas.\r\n\r\nI'll close this PR, since you'll have to open new ones from the new branches, but surely happy to review your changes in those.", "moved to #57751" ]
2,168,136,869
57,731
ENH: interleave_columns function
closed
2024-03-05T02:15:31
2024-03-25T03:45:34
2024-03-16T14:19:14
https://github.com/pandas-dev/pandas/issues/57731
true
null
null
raybellwaves
3
### Feature Type - [x] Adding new functionality to pandas - [ ] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description I would like do the equivalent in pandas as `interleave_columns` in cudf (https://docs.rapids.ai/api/cudf/legacy/user_guide/api_docs/api/cudf.dataframe.interleave_columns/) ### Feature Description Similar to the cudf example ``` df = pd.DataFrame({0: ['A1', 'A2', 'A3'], 1: ['B1', 'B2', 'B3']}) df.interleave_columns() 0 A1 1 B1 2 A2 3 B2 4 A3 5 B3 dtype: object ``` ### Alternative Solutions https://github.com/rapidsai/cudf/blob/branch-24.04/cpp/src/lists/interleave_columns.cu#L350 I got working with some numpy code but it's currently custom to the number of columns ``` pd.Series(np.ravel(np.column_stack((df[0], df[1])))) ``` ### Additional Context _No response_
[ "Enhancement", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "what about `df.T.melt()`? you can then either `set_index` the `variable` column or drop it altogether.\r\n\r\n```py\r\nIn [10]: df = pd.DataFrame({0: ['A1', 'A2', 'A3'], 1: ['B1', 'B2', 'B3'], 2: ['C1', 'C2', 'C3']})\r\n\r\nIn [11]: df\r\nOut[11]:\r\n 0 1 2\r\n0 A1 B1 C1\r\n1 A2 B2 C2\r\n2 A3 B3 C3\r\n\r\nIn [12]: df.T.melt()\r\nOut[12]:\r\n variable value\r\n0 0 A1\r\n1 0 B1\r\n2 0 C1\r\n3 1 A2\r\n4 1 B2\r\n5 1 C2\r\n6 2 A3\r\n7 2 B3\r\n8 2 C3\r\n```", "Yep agree that this should solve the problem", "I ended up finding out how to do this in the cudf test suite https://github.com/rapidsai/cudf/blob/branch-24.06/python/cudf/cudf/tests/test_reshape.py#L305 `pd.Series(np.vstack(pdf.to_numpy()).reshape((-1,)))` which is much faster than `df.T.melt()[\"value\"]`. Thanks for tip though!" ]
2,168,134,519
57,730
Replace khash + tempita with khashl
closed
2024-03-05T02:12:42
2024-04-09T03:49:01
2024-04-09T03:49:01
https://github.com/pandas-dev/pandas/pull/57730
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57730
https://github.com/pandas-dev/pandas/pull/57730
WillAyd
2
supersedes #56432 this is just a research project at the moment, but the main thing this solves is using templated functions to achieve better code organization and runtime performance, compared to what's in main. Haven't spent a ton of time optimization but first benchmark run shows factorization of a high cardinality column can be over 2x as fast, though factorizationn of a low cardinality column is 2x as slow. ```sh | Change | Before [58e63ec1] <khashl-usage~7^2> | After [23fc5842] <khashl-usage> | Ratio | Benchmark (Parameter) | |----------|----------------------------------------|-----------------------------------|---------|----------------------------------------------------------------------------------------------| | + | 1.39±0.04ms | 3.05±0.3ms | 2.19 | hash_functions.Unique.time_unique_with_duplicates('Int64') | | + | 21.4±0.8μs | 40.1±20μs | 1.88 | hash_functions.NumericSeriesIndexingShuffled.time_loc_slice(<class 'numpy.float64'>, 10000) | | + | 2.55±0.09ms | 3.96±0.2ms | 1.55 | hash_functions.Unique.time_unique('Int64') | | + | 53.5±3μs | 81.6±20μs | 1.52 | hash_functions.NumericSeriesIndexingShuffled.time_loc_slice(<class 'numpy.float64'>, 100000) | | + | 3.88±0.3ms | 5.85±0.8ms | 1.51 | hash_functions.Unique.time_unique_with_duplicates('Float64') | | + | 15.3±0.2μs | 17.2±0.6μs | 1.12 | hash_functions.NumericSeriesIndexing.time_loc_slice(<class 'numpy.float64'>, 10000) | | - | 8.46±0.3ms | 7.28±0.4ms | 0.86 | hash_functions.UniqueAndFactorizeArange.time_unique(5) | | - | 9.01±0.2ms | 7.48±0.2ms | 0.83 | hash_functions.UniqueAndFactorizeArange.time_unique(15) | | - | 8.68±0.4ms | 7.14±0.3ms | 0.82 | hash_functions.UniqueAndFactorizeArange.time_unique(4) | | - | 8.84±0.4ms | 7.23±0.1ms | 0.82 | hash_functions.UniqueAndFactorizeArange.time_unique(9) | | - | 8.86±0.4ms | 7.14±0.4ms | 0.81 | hash_functions.UniqueAndFactorizeArange.time_unique(11) | | - | 8.76±0.3ms | 6.64±0.1ms | 0.76 | hash_functions.UniqueAndFactorizeArange.time_unique(8) | | - | 14.4±1ms | 7.10±0.8ms | 0.49 | hash_functions.UniqueAndFactorizeArange.time_factorize(15) | | - | 14.7±0.9ms | 6.66±0.3ms | 0.45 | hash_functions.UniqueAndFactorizeArange.time_factorize(10) | | - | 14.7±1ms | 6.58±0.1ms | 0.45 | hash_functions.UniqueAndFactorizeArange.time_factorize(11) | | - | 15.1±2ms | 6.76±0.2ms | 0.45 | hash_functions.UniqueAndFactorizeArange.time_factorize(12) | | - | 15.4±1ms | 6.95±0.3ms | 0.45 | hash_functions.UniqueAndFactorizeArange.time_factorize(7) | | - | 15.2±1ms | 6.92±0.4ms | 0.45 | hash_functions.UniqueAndFactorizeArange.time_factorize(8) | | - | 14.9±1ms | 6.60±0.2ms | 0.44 | hash_functions.UniqueAndFactorizeArange.time_factorize(4) | | - | 15.4±1ms | 6.69±0.1ms | 0.44 | hash_functions.UniqueAndFactorizeArange.time_factorize(5) | | - | 15.3±1ms | 6.77±0.2ms | 0.44 | hash_functions.UniqueAndFactorizeArange.time_factorize(6) | | - | 15.7±0.8ms | 6.27±0.1ms | 0.4 | hash_functions.UniqueAndFactorizeArange.time_factorize(9) | SOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY. PERFORMANCE DECREASED. ```
[ "Performance", "Stale" ]
0
0
0
0
0
0
0
0
[ "This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.", "Will reopen if I get time to look at this again. Generally the idea is promising just takes some time to get the benchmarks right" ]
2,167,827,238
57,729
Backport PR #57721 on branch 2.2.x (update from 2022 to 2024 image)
closed
2024-03-04T21:45:00
2024-03-04T22:46:47
2024-03-04T22:46:47
https://github.com/pandas-dev/pandas/pull/57729
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57729
https://github.com/pandas-dev/pandas/pull/57729
meeseeksmachine
0
Backport PR #57721: update from 2022 to 2024 image
[ "Build", "CI" ]
0
0
0
0
0
0
0
0
[]
2,167,755,559
57,728
Backport PR #57726: TST/CI: Fix test_repr on musl for dateutil 2.9
closed
2024-03-04T21:06:44
2024-03-04T22:45:42
2024-03-04T22:45:38
https://github.com/pandas-dev/pandas/pull/57728
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57728
https://github.com/pandas-dev/pandas/pull/57728
mroeschke
0
null
[ "Testing", "CI" ]
0
0
0
0
0
0
0
0
[]
2,167,624,589
57,727
CI: locking `pytest` version = `8.1.0`
closed
2024-03-04T19:50:33
2024-03-04T22:48:23
2024-03-04T22:02:05
https://github.com/pandas-dev/pandas/pull/57727
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57727
https://github.com/pandas-dev/pandas/pull/57727
natmokval
3
- [x] closes #57718 locked `pytest` to version more then `8.1.0`, as a temporary solution. the reason: with the latest `pytest` version `8.1.0` we get an error when runninig pytest ``` File "/home/panda/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_manager.py", line 342, in _verify_hook raise PluginValidationError( pluggy._manager.PluginValidationError: Plugin 'pytest_cython' for hook 'pytest_collect_file' hookimpl definition: pytest_collect_file(path, parent) Argument(s) {'path'} are declared in the hookimpl but can not be found in the hookspec ``` I think, it’s a bug in the last version of `pytest-cython-0.2.1` (see [link](https://github.com/lgpage/pytest-cython/issues/59)) which is related to enforcing deprecation of `path` parameter in the last version of `pytest 8.1.0` (see [link](https://github.com/pytest-dev/pytest/issues/11779))
[]
0
0
0
0
0
0
0
0
[ "I think the pytest devs just yanked 8.1 from pypi and conda forge so we may not need this anymore: https://github.com/pytest-dev/pytest/issues/12069\r\n\r\ne.g. https://github.com/pandas-dev/pandas/actions/runs/8146954729/job/22266609711#step:4:427", "indeed, seems we don't need this anymore. Thank you, @mroeschke, I will close this PR.", "Thanks for being proactive on this!" ]
2,167,586,505
57,726
TST/CI: Fix test_repr on musl for dateutil 2.9
closed
2024-03-04T19:29:02
2024-03-04T21:13:37
2024-03-04T21:03:44
https://github.com/pandas-dev/pandas/pull/57726
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57726
https://github.com/pandas-dev/pandas/pull/57726
mroeschke
2
null
[ "Testing", "CI" ]
0
0
0
0
0
0
0
0
[ "Merging to get part of the CI to green", "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 c3ae17d04d3993e1c3e4c0f8824fde03b8c9beac\n```\n\n3. You will likely have some merge/cherry-pick conflict here, fix them and commit:\n\n```\ngit commit -am 'Backport PR #57726: TST/CI: Fix test_repr on musl for dateutil 2.9'\n```\n\n4. Push to a named branch:\n\n```\ngit push YOURFORK 2.2.x:auto-backport-of-pr-57726-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 #57726 on branch 2.2.x (TST/CI: Fix test_repr on musl for dateutil 2.9)\"\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,167,293,513
57,725
[pre-commit.ci] pre-commit autoupdate
closed
2024-03-04T16:49:11
2024-03-07T22:57:36
2024-03-07T22:57:32
https://github.com/pandas-dev/pandas/pull/57725
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57725
https://github.com/pandas-dev/pandas/pull/57725
pre-commit-ci[bot]
1
<!--pre-commit.ci start--> updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.13 → v0.3.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.13...v0.3.0) - [github.com/jendrikseipp/vulture: v2.10 → v2.11](https://github.com/jendrikseipp/vulture/compare/v2.10...v2.11) - [github.com/pylint-dev/pylint: v3.0.1 → v3.1.0](https://github.com/pylint-dev/pylint/compare/v3.0.1...v3.1.0) - [github.com/PyCQA/isort: 5.12.0 → 5.13.2](https://github.com/PyCQA/isort/compare/5.12.0...5.13.2) - [github.com/asottile/pyupgrade: v3.15.0 → v3.15.1](https://github.com/asottile/pyupgrade/compare/v3.15.0...v3.15.1) <!--pre-commit.ci end-->
[ "Code Style" ]
0
0
0
0
0
0
0
0
[ "Since ruff was bumped https://github.com/pandas-dev/pandas/pull/57766 and other other dependencies are not critical. We'll wait until next month" ]
2,167,216,233
57,724
BUG: to_sql does not get the correct dialect
closed
2024-03-04T16:13:06
2024-07-09T00:04:46
2024-07-09T00:04:46
https://github.com/pandas-dev/pandas/issues/57724
true
null
null
sls-mdr
6
### 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 urllib.parse import pandas as pd import sqlalchemy username = "SOME_USERNAME" password = urllib.parse.quote("SOME_PASSWORD") host = "SOME_HOST" port = SOME_PORT # connection to denodo plattform conn_str = f"denodo://{username}:{password}@{host}:{port}/dv_tutorial" print("________________________") print(conn_str) print(type(conn_str)) engine = sqlalchemy.create_engine(conn_str, echo=True) # read is possible result_set = engine.execute("SELECT * FROM dv_tutorial.test") for row in result_set: print(row) # write is not possible with engine.connect() as conn: print("BBBBBBBBBBBBBB") print(type(conn)) df1 = pd.DataFrame({"name": ["User 4", "User 5"]}) # :arrowdown: this produces the error df1.to_sql( name="test_table", schema="dv_tutorial", con=conn.connection, index=False, ) ``` ### Issue Description We want to connect to denodo Platform and create a table with pd.to_sql(). The output shows in our opinion that it can not get the correct dialect. It tries to check if the table already exists in a SQL Lite DB. ``` (dbaccess) []$ /bin/python3.11 ./dbaccess/test.py ________________________ denodo://SOME_PARAMS/dv_tutorial <class 'str'> ./dbaccess/test.py:20: RemovedIn20Warning: Deprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to "sqlalchemy<2.0". Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings. Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silence this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9) result_set = engine.execute("SELECT * FROM dv_tutorial.test") 2024-03-04 16:23:16,383 INFO sqlalchemy.engine.Engine select current_schema() 2024-03-04 16:23:16,383 INFO sqlalchemy.engine.Engine [raw sql] {} 2024-03-04 16:23:16,428 INFO sqlalchemy.engine.Engine SELECT * FROM dv_tutorial.test 2024-03-04 16:23:16,429 INFO sqlalchemy.engine.Engine [raw sql] {} (1,) BBBBBBBBBBBBBB <class 'sqlalchemy.engine.base.Connection'> ./dbaccess/test.py:29: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy. df1.to_sql( Traceback (most recent call last): File "/home/s901193/.local/lib/python3.11/site-packages/pandas/io/sql.py", line 2672, in execute cur.execute(sql, *args) psycopg2.OperationalError: Syntax error: Invalid parameterized expression DETAIL: java.sql.SQLException: Syntax error: Invalid parameterized expression The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/s901193/tkdbaccess/silas.py", line 29, in <module> df1.to_sql( File "/home/s901193/.local/lib/python3.11/site-packages/pandas/util/_decorators.py", line 333, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/s901193/.local/lib/python3.11/site-packages/pandas/core/generic.py", line 3084, in to_sql return sql.to_sql( ^^^^^^^^^^^ File "/home/s901193/.local/lib/python3.11/site-packages/pandas/io/sql.py", line 842, in to_sql return pandas_sql.to_sql( ^^^^^^^^^^^^^^^^^^ File "/home/s901193/.local/lib/python3.11/site-packages/pandas/io/sql.py", line 2848, in to_sql table.create() File "/home/s901193/.local/lib/python3.11/site-packages/pandas/io/sql.py", line 984, in create if self.exists(): ^^^^^^^^^^^^^ File "/home/s901193/.local/lib/python3.11/site-packages/pandas/io/sql.py", line 970, in exists return self.pd_sql.has_table(self.name, self.schema) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/s901193/.local/lib/python3.11/site-packages/pandas/io/sql.py", line 2863, in has_table return len(self.execute(query, [name]).fetchall()) > 0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/s901193/.local/lib/python3.11/site-packages/pandas/io/sql.py", line 2684, in execute raise ex from exc pandas.errors.DatabaseError: Execution failed on sql ' SELECT name FROM sqlite_master WHERE type IN ('table', 'view') AND name=?; ': Syntax error: Invalid parameterized expression DETAIL: java.sql.SQLException: Syntax error: Invalid parameterized expression ``` ### Expected Behavior We want to use pd.to_sql() to write a table into denodo plattform and use the dialect from the string. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.5.final.0 python-bits : 64 OS : Linux OS-release : 4.18.0-513.11.1.el8_9.x86_64 Version : #1 SMP Thu Dec 7 03:06:13 EST 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.1 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.9.0.post0 setuptools : 69.0.3 pip : 24.0 Cython : None pytest : 8.0.2 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : 2.9.9 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 : 2024.1 qtpy : None pyqt5 : None </details> AND pip list Package Version ----------------- ----------- denodo-sqlalchemy 20240229 greenlet 3.0.3 hdbcli 2.19.21 numpy 1.26.4 pandas 2.2.1 pip 23.3.1 polars 0.20.13 psycopg2-binary 2.9.9 pyarrow 15.0.0 python-dateutil 2.9.0.post0 pytz 2024.1 setuptools 69.0.2 six 1.16.0 SQLAlchemy 1.4.51 sqlalchemy-hana 1.3.0 typing_extensions 4.10.0 tzdata 2024.1 wheel 0.42.0
[ "Bug", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "pandas 2.2 doesn't support sqlalchemy < 2 https://pandas.pydata.org/docs/getting_started/install.html#sql-databases \r\n\r\nI think there are open issues under discussion to re-add support for 1.4.x", "I came across the same issue today when I wanted to upload data to Snowflake using the .to_sql() method.\r\n\r\nLooks like neither snowflake-sqlalchemy nor the latest Apache Airflow release support SQLAlchemy 2 yet. Having support for 1.4.x re-added would be really helpful.", "xref: #57049", "So @asishm should I close this one?", "If you can confirm that it works with pandas<2.2 and sqla 1.4.x, then imo it can be closed as a duplicate of the linked issue. But if you want to wait for a pandas core dev to respond, that's probably fine as well.", "Closing as a dupe of https://github.com/pandas-dev/pandas/issues/57049" ]
2,167,029,070
57,723
BUG: fillna() doesn't work with `value=None` without method specified, but method is deprecated
closed
2024-03-04T14:49:11
2024-04-15T17:22:41
2024-04-15T17:22:41
https://github.com/pandas-dev/pandas/issues/57723
true
null
null
Dr-Irv
6
### 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 >>> s = pd.Series([1,None,3]) >>> s 0 1.0 1 NaN 2 3.0 dtype: float64 >>> s.fillna() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Code\pandas_dev\pandas\pandas\core\generic.py", line 6887, in fillna value, method = validate_fillna_kwargs(value, method) File "C:\Code\pandas_dev\pandas\pandas\util\_validators.py", line 293, in validate_fillna_kwargs raise ValueError("Must specify a fill 'value' or 'method'.") ValueError: Must specify a fill 'value' or 'method'. >>> s.fillna(value=None, method="ffill") <stdin>:1: FutureWarning: Series.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead. 0 1.0 1 1.0 2 3.0 dtype: float64 ``` ### Issue Description The `method` parameter is deprecated in version 2.1. But the docs for `Series.fillna()` indicate that a value of `None` is valid. So you can't do a `fillna()` with a value of `None` ### Expected Behavior Unclear. Do we want to allow `None` as the possible value in fillna()? This could be a docs issue or a code issue. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.10.13.final.0 python-bits : 64 OS : Linux OS-release : 4.4.0-19041-Microsoft Version : #3996-Microsoft Thu Jan 18 16:36:00 PST 2024 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.1.0 pip : 23.2.1 Cython : None pytest : 8.0.1 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 : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Missing-data" ]
0
0
0
0
0
0
0
0
[ "I believe this issue existed prior to the deprecation: it was never possible to just `.fillna(value=None)`. And doing `.fillna(value=None, method=\"ffill\")` would ignore the `value` parameter (since forward filling does not utilize a value). When the deprecation is enforced, we can make the `value` parameter required (instead of having a default), and then enable users to use `.fillna(value=None)`.", "Ref: #47639", "> I believe this issue existed prior to the deprecation: it was never possible to just `.fillna(value=None)`. And doing `.fillna(value=None, method=\"ffill\")` would ignore the `value` parameter (since forward filling does not utilize a value). When the deprecation is enforced, we can make the `value` parameter required (instead of having a default), and then enable users to use `.fillna(value=None)`.\r\n\r\nSo should we update the docs now to reflect that `Series.fillna(value=None)` doesn't work? Because the way it reads now, it appears that it should work. I think that is what led to the confusion of the OP in https://github.com/pandas-dev/pandas-stubs/issues/884\r\n", "> So should we update the docs now to reflect that Series.fillna(value=None) doesn't work?\r\n\r\nI would vote no, but not opposed if someone wants to do that. This deficiency in the docs has existed for a long time, and I expect it to work come 3.0, so it doesn't seem worth the effort to change now.", "agree with @rhshadrach ", "I have a PR in the works for enforcing said deprecation, I'll add a test for this and use that PR to close this issue." ]
2,166,895,740
57,722
DOC: SQL-style join conditions
open
2024-03-04T13:49:30
2025-07-25T06:34:06
null
https://github.com/pandas-dev/pandas/issues/57722
true
null
null
jxu
11
### 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/getting_started/comparison/comparison_with_sql.html ### Documentation problem Not described how to do more complicated SQL-like joins on conditions, such as ```sql SELECT * FROM A LEFT JOIN B ON A.key = B.key AND A.a >= B.b ``` ### Suggested fix for documentation Something from https://stackoverflow.com/questions/23508351/how-to-do-workaround-a-conditional-join-in-python-pandas This is a common operation and a canonical answer is useful
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "@jxu you could contribute a PR to add this to the docs", "I'm not familiar with SQL mechanics but does it actually only merge on rows that `A.a >= B.b` evaluates true or does it match on `A.key = B.key` first and then filter it further with `A.a >= B.b` (meaning there's some intermediate result)?\r\n\r\nIf it's the latter, then I suppose an example showing the merge followed by a query could be done but I believe that's inferable from the current examples.\r\n\r\nTo my knowledge there is no way to do the former with pandas", "I'm not actually sure how to do this. My understanding of LEFT JOIN in SQL is logically \r\n1. Cartesian Product\r\n2. Filter rows based on condition\r\n3. Give rows not matched from left table nulls \r\n\r\nSo I think the pandas merge is join but only on keys... you could do what I wrote step by step, but I think the product step would be expensive in implementation ", "Merging on the keys and then filtering is usually what SQL does as well (if there is an equality condition). ", "That's the logical result, but the SQL engine can run it in a way that's more efficient. But if I write it as two steps in pandas, the whole cross product is calculated before any filtering.", "> I'm not familiar with SQL mechanics but does it actually only merge on rows that `A.a >= B.b` evaluates true or does it match on `A.key = B.key` first and then filter it further with `A.a >= B.b` (meaning there's some intermediate result)?\r\n> \r\n> If it's the latter, then I suppose an example showing the merge followed by a query could be done but I believe that's inferable from the current examples.\r\n> \r\n> To my knowledge there is no way to do the former with pandas\r\n\r\nThe SQL join condition is applied once, so there's no logical distinction between the key condition and any other condition.", "@jxu I'm not sure what you mean by cross product. A merge on the equal keys is not a cross product", "Cartesian product or cross join. Cross product is something for vector spaces ", "@jxu if you are running an equi join with a non equi join in pandas, then there is no Cartesian join. The join is executed first on the equi join, followed by the non equi join(which is a filter on the results of the equi join). SQL does the same but in a transparent way - an EXPLAIN plan will likely show an equi join followed by a non equi join filter", "ok, I did not know that ", "take" ]
2,166,855,523
57,721
update from 2022 to 2024 image
closed
2024-03-04T13:29:47
2024-03-29T07:59:02
2024-03-04T21:44:35
https://github.com/pandas-dev/pandas/pull/57721
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57721
https://github.com/pandas-dev/pandas/pull/57721
lopof
1
- [x] closes #57719 - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Build", "CI" ]
0
0
0
0
0
0
0
0
[ "Thanks for identifying @lopof. Looks like `default` maps to a LTS version and is avoiding the brownout period so going to merge for now. If needed we can pin to a specific image in a follow up " ]
2,166,841,858
57,720
DOC: Remove references to `bfill`, `ffill`, `pad`, and `backfill` in `limit_direction`
closed
2024-03-04T13:23:07
2024-03-05T02:50:41
2024-03-05T02:50:35
https://github.com/pandas-dev/pandas/pull/57720
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57720
https://github.com/pandas-dev/pandas/pull/57720
sjalkote
1
Picked up issue #57092. This removes references to `bfill`, `ffill`, `pad`, `backfill` from `limit_direction` as they aren't supported. Also references `bfill` and `ffill` in the "See Also" section. Up to date with latest commit. - [X] closes #57092 - [ ] [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" ]
0
0
0
0
0
0
0
0
[ "Thanks @TechnoShip123 " ]
2,166,822,156
57,719
BUG: Circle CI deprecates images
closed
2024-03-04T13:13:24
2024-03-04T21:44:36
2024-03-04T21:44:36
https://github.com/pandas-dev/pandas/issues/57719
true
null
null
lopof
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 Ci tests failing because "This job was rejected because the image is unavailable" ``` ### Issue Description Circle CI deprecates images: https://discuss.circleci.com/t/linux-image-deprecations-and-eol-for-2024/50177. ### Expected Behavior Update to supported images ### Installed Versions <details> all </details>
[ "Bug", "Needs Triage" ]
0
0
0
0
0
0
0
0
[]
2,166,725,580
57,718
BUG: Pytest Version >=8.1
closed
2024-03-04T12:23:51
2024-03-04T22:31:17
2024-03-04T22:31:17
https://github.com/pandas-dev/pandas/issues/57718
true
null
null
lopof
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. - [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 pytest /path/to/any/test.py ``` ### Issue Description With pytest version 8.1 this issue pops up locally at my test environment: https://github.com/pytest-dev/pytest/issues/11779 ``` Traceback (most recent call last): File "/home/tom/miniforge3/envs/pandas-dev/bin/pytest", line 10, in <module> sys.exit(console_main()) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/_pytest/config/__init__.py", line 195, in console_main code = main() File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/_pytest/config/__init__.py", line 153, in main config = _prepareconfig(args, plugins) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/_pytest/config/__init__.py", line 335, in _prepareconfig config = pluginmanager.hook.pytest_cmdline_parse( File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_hooks.py", line 501, in __call__ return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_manager.py", line 119, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_callers.py", line 138, in _multicall raise exception.with_traceback(exception.__traceback__) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_callers.py", line 121, in _multicall teardown.throw(exception) # type: ignore[union-attr] File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/_pytest/helpconfig.py", line 105, in pytest_cmdline_parse config = yield File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_callers.py", line 102, in _multicall res = hook_impl.function(*args) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1141, in pytest_cmdline_parse self.parse(args) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1490, in parse self._preparse(args, addopts=addopts) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1377, in _preparse self.pluginmanager.load_setuptools_entrypoints("pytest11") File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_manager.py", line 415, in load_setuptools_entrypoints self.register(plugin, name=ep.name) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/_pytest/config/__init__.py", line 497, in register plugin_name = super().register(plugin, name) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_manager.py", line 167, in register self._verify_hook(hook, hookimpl) File "/home/tom/miniforge3/envs/pandas-dev/lib/python3.10/site-packages/pluggy/_manager.py", line 342, in _verify_hook raise PluginValidationError( pluggy._manager.PluginValidationError: Plugin 'pytest_cython' for hook 'pytest_collect_file' hookimpl definition: pytest_collect_file(path, parent) Argument(s) {'path'} are declared in the hookimpl but can not be found in the hookspec ``` ### Expected Behavior Run pytests without setup errors ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : a38ecd5b84a96ae1453e889f3dfebb0d218a575c python : 3.10.13.final.0 python-bits : 64 OS : Linux OS-release : 6.5.0-21-generic Version : #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 9 13:32:52 UTC 2 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.dev0+730.ga38ecd5b84.dirty numpy : 1.26.4 pytz : 2024.1 dateutil : 2.9.0 setuptools : 68.2.2 pip : 24.0 Cython : 3.0.8 pytest : 8.1.0 hypothesis : 6.98.17 sphinx : 6.2.1 blosc : None feather : None xlsxwriter : 3.1.9 lxml.etree : 5.1.0 html5lib : 1.1 pymysql : 1.4.6 psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : 8.22.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.8 fastparquet : 2024.2.0 fsspec : 2024.2.0 gcsfs : 2024.2.0 matplotlib : 3.8.3 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pyarrow : 15.0.0 pyreadstat : 1.2.6 python-calamine : None pyxlsb : 1.0.10 s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.27 tables : 3.9.2 tabulate : 0.9.0 xarray : 2024.2.0 xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Testing", "CI", "Closing Candidate" ]
1
0
0
0
0
0
0
0
[ "thanks @lopof for reporting this.\r\n\r\nthe reason for this failure: in pytest version 8.1 `py.path` hook parameters are removed ([see](https://github.com/pytest-dev/pytest/issues/11779)). The simplest thing we can do is to add in `environment.yml` additional dependency `- pytest>=7.3.2,<8.1.0`\r\n\r\nHowever, it would be better to update usage of pytest so that it passes with the latest pytest version. I would like to work on this.", "8.1 has been yanked, and it sounds like the maintainers will revert the removal for 8.1.1. I think this can be closed." ]
2,166,644,671
57,717
BUILD: error: metadata-generation-failed; ninja: build stopped: subcommand failed.
closed
2024-03-04T11:44:15
2024-03-07T11:22:18
2024-03-07T11:22:18
https://github.com/pandas-dev/pandas/issues/57717
true
null
null
Rand-0
5
### Installation check - [X] I have read the [installation guide](https://pandas.pydata.org/pandas-docs/stable/getting_started/install.html#installing-pandas). ### Platform Windows-10-10.0.19045-SP0 ### Installation Method pip install ### pandas Version 2.2.1 ### Python Version 3.9 ### Installation Logs <details> Collecting pandas Using cached pandas-2.2.1.tar.gz (4.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [81 lines of output] + meson setup C:\Users\kacpe\AppData\Local\Temp\pip-install-iagl7i7u\pandas_e56223d9bb2546b6958431903a3af4f1 C:\Users\kacpe\AppData\Local\Temp\pip-install-iagl7i7u\pandas_e56223d9bb2546b6958431903a3af4f1\.mesonpy-uiyqxkyb\build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --vsenv --native-fi le=C:\Users\kacpe\AppData\Local\Temp\pip-install-iagl7i7u\pandas_e56223d9bb2546b6958431903a3af4f1\.mesonpy-uiyqxkyb\build\meson-python-native-file.ini The Meson build system Version: 1.2.1 Source dir: C:\Users\kacpe\AppData\Local\Temp\pip-install-iagl7i7u\pandas_e56223d9bb2546b6958431903a3af4f1 Build dir: C:\Users\kacpe\AppData\Local\Temp\pip-install-iagl7i7u\pandas_e56223d9bb2546b6958431903a3af4f1\.mesonpy-uiyqxkyb\build Build type: native build Project name: pandas Project version: 2.2.1 Activating VS 17.9.2 C compiler for the host machine: cl (msvc 19.39.33521 "Microsoft (R) C/C++ wersja kompilatora optymalizujĄcego 19.39.33521 dla x64") C linker for the host machine: link link 14.39.33521.0 C++ compiler for the host machine: cl (msvc 19.39.33521 "Microsoft (R) C/C++ wersja kompilatora optymalizujĄcego 19.39.33521 dla x64") C++ linker for the host machine: link link 14.39.33521.0 Cython compiler for the host machine: cython (cython 3.0.5) Host machine cpu family: x86_64 Host machine cpu: x86_64 Program python found: YES (D:\python\Lion\venv\bin\python.exe) Found pkg-config: d:\msys\mingw64\bin\pkg-config.EXE (1.8.0) Run-time dependency python found: YES 3.10 Build targets in project: 53 pandas 2.2.1 User defined options Native files: C:\Users\kacpe\AppData\Local\Temp\pip-install-iagl7i7u\pandas_e56223d9bb2546b6958431903a3af4f1\.mesonpy-uiyqxkyb\build\meson-python-native-file.ini buildtype : release vsenv : True b_ndebug : if-release b_vscrt : md Found ninja.EXE-1.11.1.git.kitware.jobserver-1 at C:\Users\kacpe\AppData\Local\Temp\pip-build-env-wfo92fd8\normal\bin\ninja.EXE Visual Studio environment is needed to run Ninja. It is recommended to use Meson wrapper: D:\python\Lion\venv\bin\meson compile -C . + meson compile [1/151] Generating pandas/_libs/algos_take_helper_pxi with a custom command [2/151] Generating pandas/_libs/algos_common_helper_pxi with a custom command [3/151] Generating pandas/_libs/khash_primitive_helper_pxi with a custom command [4/151] Generating pandas/_libs/hashtable_class_helper_pxi with a custom command [5/151] Generating pandas/_libs/hashtable_func_helper_pxi with a custom command [6/151] Generating pandas/_libs/index_class_helper_pxi with a custom command [7/151] Generating pandas/_libs/sparse_op_helper_pxi with a custom command [8/151] Generating pandas/_libs/intervaltree_helper_pxi with a custom command [9/151] Generating pandas/__init__.py with a custom command [10/151] Compiling C object pandas/_libs/tslibs/parsing.cp310-mingw_x86_64.pyd.p/.._src_parser_tokenizer.c.obj FAILED: pandas/_libs/tslibs/parsing.cp310-mingw_x86_64.pyd.p/.._src_parser_tokenizer.c.obj "cl" "-Ipandas\_libs\tslibs\parsing.cp310-mingw_x86_64.pyd.p" "-Ipandas\_libs\tslibs" "-I..\..\pandas\_libs\tslibs" "-I..\..\..\..\pip-build-env-wfo92fd8\overlay\lib\python3.10\site-packages\numpy\core\include" "-I..\..\pandas\_libs\include" "-Id:/msys/mingw64/bin/../include/python3.10" "-DNDEBUG" "/M D" "/nologo" "/showIncludes" "/utf-8" "/W3" "/std:c11" "/O2" "/Gw" "-DNPY_NO_DEPRECATED_API=0" "-DNPY_TARGET_VERSION=NPY_1_21_API_VERSION" "/Fdpandas\_libs\tslibs\parsing.cp310-mingw_x86_64.pyd.p\.._src_parser_tokenizer.c.pdb" /Fopandas/_libs/tslibs/parsing.cp310-mingw_x86_64.pyd.p/.._src_parser_tokenizer.c .obj "/c" ../../pandas/_libs/src/parser/tokenizer.c d:/msys/mingw64/bin/../include/python3.10\Python.h(36): fatal error C1083: Nie moľna otworzy† pliku do\x88Ącz: 'unistd.h': No such file or directory [11/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/indexing.pyx [12/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/base.pyx [13/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/ccalendar.pyx [14/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/dtypes.pyx [15/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/nattype.pyx warning: C:\Users\kacpe\AppData\Local\Temp\pip-install-iagl7i7u\pandas_e56223d9bb2546b6958431903a3af4f1\pandas\_libs\tslibs\nattype.pyx:79:0: Global name __nat_unpickle matched from within class scope in contradiction to to Python 'class private name' rules. This may change in a future release. warning: C:\Users\kacpe\AppData\Local\Temp\pip-install-iagl7i7u\pandas_e56223d9bb2546b6958431903a3af4f1\pandas\_libs\tslibs\nattype.pyx:79:0: Global name __nat_unpickle matched from within class scope in contradiction to to Python 'class private name' rules. This may change in a future release. [16/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/np_datetime.pyx [17/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/arrays.pyx [18/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/hashing.pyx [19/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/vectorized.pyx [20/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/timezones.pyx [21/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/fields.pyx [22/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/tzconversion.pyx [23/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/internals.pyx [24/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/parsing.pyx [25/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/conversion.pyx [27/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/timestamps.pyx [28/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/timedeltas.pyx [29/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/period.pyx [30/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/tslibs/offsets.pyx [31/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/index.pyx [32/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/interval.pyx [33/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/hashtable.pyx [34/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/algos.pyx [35/151] Compiling Cython source C:/Users/kacpe/AppData/Local/Temp/pip-install-iagl7i7u/pandas_e56223d9bb2546b6958431903a3af4f1/pandas/_libs/groupby.pyx ninja: build stopped: subcommand failed. Activating VS 17.9.2 INFO: automatically activated MSVC compiler environment INFO: autodetecting backend as ninja INFO: calculating backend command to run: C:\Users\kacpe\AppData\Local\Temp\pip-build-env-wfo92fd8\normal\bin\ninja.EXE [end of output] </details>
[ "Build", "Needs Info" ]
0
0
0
0
0
0
0
0
[ "> d:/msys/mingw64/bin/../include/python3.10\\Python.h(36): fatal error C1083: Nie moľna otworzy† pliku do\\x88Ącz: 'unistd.h': No such file or directory\r\n\r\nLooks this same as this: https://github.com/pyproj4/pyproj/issues/1009#issuecomment-1025907214\r\n\r\nCan you try the resolution here: https://github.com/pyproj4/pyproj/issues/1009#issuecomment-1225740999\r\n\r\nNamely, run:\r\n\r\n SETUPTOOLS_USE_DISTUTILS=stdlib pip install pandas", "Hey, I'm kinda new to python - from where am I suppose to run it? I'm using pycharm as IDE and msys2 separetely for C++", "Where you ran `pip install`.", "SETUPTOOLS_USE_DISTUTILS=stdlib pip install pandas\r\nSETUPTOOLS_USE_DISTUTILS=stdlib : The term 'SETUPTOOLS_USE_DISTUTILS=stdlib' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\nAt line:1 char:1 \r\n+ SETUPTOOLS_USE_DISTUTILS=stdlib pip install pandas \r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \r\n + CategoryInfo : ObjectNotFound: (SETUPTOOLS_USE_DISTUTILS=stdlib:String) [], CommandNotFoundException\r\n + FullyQualifiedErrorId : CommandNotFoundException ", "I run it as `$env:SETUPTOOLS_USE_DISTUTILS = \"stdlib\"; pip install pandas` - but nothing changes" ]
2,165,790,488
57,716
Pandas Extension: Drop Duplicated Columns
closed
2024-03-04T02:39:48
2024-03-06T22:01:05
2024-03-06T22:01:05
https://github.com/pandas-dev/pandas/issues/57716
true
null
null
kanhapatil
2
### Feature Type - [X] Adding new functionality to pandas - [ ] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description When working with datasets in pandas, users often encounter the need to identify and handle duplicated columns. The presence of duplicated columns can complicate data analysis, lead to redundancy, and affect computational efficiency. Currently, pandas lacks a built-in method to easily drop duplicated columns from a DataFrame. ### Feature Description The proposed feature introduces a new functionality to pandas, enabling users to drop duplicated columns from a DataFrame effortlessly. This is achieved through the addition of a drop_duplicated_columns method within a new class named DuplicateCols. ### Alternative Solutions import pandas as pd data = pd.DataFrame({ 'A' : [1,2,3,4,5], 'B' : [10,20,30,40,50], 'C' : [2,4,6,8,10], 'D' : [10,20,30,40,50], 'E' : [1,2,3,4,5], 'F' : [1,2,3,4,5], }) class DuplicateCols: def __init__(self, dataset): self.temp = set() self.dupCols = [] self.nonDupCols = [] self.compareCols = [] self.dataset = dataset def duplicateColumns(self): for col in self.dataset.columns: col_data = tuple(self.dataset[col]) if col_data in self.temp: self.dupCols.append(col) else: self.temp.add(col_data) self.nonDupCols.append(col) return self.dupCols def nonDuplicateColumns(self): self.duplicateColumns() return self.nonDupCols def dropDuplicateColumns(self): self.duplicateColumns() return self.dataset[self.nonDupCols] # Example Usage: duplicates = DuplicateCols(data) print("Duplicated Columns:", duplicates.duplicateColumns()) print("Non-Duplicated Columns:", duplicates.nonDuplicateColumns()) result_df = duplicates.dropDuplicateColumns() print("DataFrame after dropping duplicated columns:") print(result_df) ### Additional Context _No response_
[ "Enhancement", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "It seems like the current implementation of the feature focuses on detecting duplicated columns based on the values they contain, but it may not handle cases where columns have the same names. ", "You can simply do:\r\n\r\n```\r\ndf = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], columns=[\"a\", \"a\", \"c\"])\r\ndf.loc[:, ~df.columns.duplicated(keep=\"first\")]\r\n```\r\n\r\n-1 on adding this to the api" ]
2,165,598,758
57,715
CLN: remove references to `is_anchored` from ci/code_checks.sh
closed
2024-03-03T22:29:12
2024-03-04T18:25:52
2024-03-04T18:25:51
https://github.com/pandas-dev/pandas/pull/57715
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57715
https://github.com/pandas-dev/pandas/pull/57715
natmokval
0
xref# #57473 removed references to removed method `is_anchored` from `ci/code_checks.sh`
[ "CI", "Clean" ]
0
0
0
0
0
0
0
0
[]
2,165,450,464
57,714
#48188 FIX: iloc works with namedtuple
closed
2024-03-03T16:55:55
2024-03-04T20:10:21
2024-03-04T20:10:21
https://github.com/pandas-dev/pandas/pull/57714
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57714
https://github.com/pandas-dev/pandas/pull/57714
Deadlica
2
- unit test for added for test_iloc.py that verifies that all four uses of iloc given in the reproducible example now works - [x] closes #48188 - [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
[]
0
0
0
0
0
0
0
0
[ "@WillAyd could you review this pr?", "Thanks for the PR, but there's already a PR open addressing this issue https://github.com/pandas-dev/pandas/pull/57004\r\n\r\nClosing to let that user still work on that issue but happy to have your help on another `good first issue`" ]
2,165,418,794
57,713
BUG: Line plots aligned from start #57594
closed
2024-03-03T15:34:23
2024-04-15T17:24:19
2024-04-15T17:24:18
https://github.com/pandas-dev/pandas/pull/57713
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57713
https://github.com/pandas-dev/pandas/pull/57713
NoelMT
5
#57594 BUG: df.plot makes a shift to the right if frequency multiplies to n > 1 The cause of this bug is that by default all elements are generated to align to the end of a period instead of at the start and the period technically does not end at the start of the last period but rather just before the period subsequent to the last period. To fix this problem we therefore passed a parameter stating that the elements should be aligned to the start of the period instead of the end. Parameter "how=S" was added in pandas/plotting/_matplotlib/timeseries.py::maybe_convert_index(), on the function call data.index.asfreq(freq=freq_str, how = "S"). Additional tests were added to test whether input data match data in plot and one test was merged into one the added test to reduce code duplication.
[ "Visualization", "Stale" ]
0
0
0
0
0
0
0
0
[ "Thank you for working on this @NoelMT. Do you mind adding plots to this PR (as a comment or in the description) that show how things are rendered before and after your changes please? That would give context to reviewers and it'll make reviewing much easier. Thanks! ", "Thanks @NoelMT for working on this. Seems like it will fix the problem with visualisation of `DataFrame` if `PeriodIndex` as index provided.\r\ne.g. for the first scenario:\r\n```\r\nfrom pandas import *\r\nimport numpy as np\r\n\r\nidx = period_range(\"01/01/2000\", freq='7h', periods=4)\r\ndf = DataFrame(\r\n np.array([0, 1, 0, 1]),\r\n index=idx,\r\n columns=[\"A\"],\r\n)\r\ndf.plot()\r\nprint(df)\r\n```\r\n\r\nplot before:\r\n\r\n<img width=\"552\" alt=\"res_7h\" src=\"https://github.com/pandas-dev/pandas/assets/91160475/47bccd86-a957-42e1-b021-de15e63cf85e\">\r\n\r\nplot after:\r\n\r\n<img width=\"620\" alt=\"dfplot_7h_correct\" src=\"https://github.com/pandas-dev/pandas/assets/91160475/235ed96a-8b94-4d50-9cb4-181a387e9242\">\r\n", "@NoelMT could you please add a note to `doc/source/whatsnew/v3.0.0.rst` in the section\r\nhttps://github.com/pandas-dev/pandas/blob/dc19148bf7197a928a129b1d1679b1445a7ea7c7/doc/source/whatsnew/v3.0.0.rst?plain=1#L356\r\n", "This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.", "Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen." ]
2,165,342,657
57,712
Potential regression induced by PR #57588
closed
2024-03-03T12:50:21
2024-03-16T13:41:11
2024-03-16T13:41:11
https://github.com/pandas-dev/pandas/issues/57712
true
null
null
DeaMariaLeon
1
PR #57588 If this is expected please ignore this issue. The largest regressions seem to be the benchmarks bellow. edit: the names of all the benchmarks with links to their plot are in the attached file. `series_methods.Dropna.time_dropna` (Python) with dtype='datetime' `groupby.GroupByMethods.time_dtype_as_field` (Python) with application='direct', dtype='int16', method='head', ncols=1, param5='cython' `groupby.Nth.time_series_nth_all` (Python) with dtype='datetime' @mroeschke [cleaned_regression_file.json](https://github.com/pandas-dev/pandas/files/14473488/cleaned_regression_file.json) ![Screenshot 2024-03-03 at 13 26 15](https://github.com/pandas-dev/pandas/assets/11835246/8f8432af-42b5-42e4-827e-a8805bd28e59)
[ "Benchmark" ]
0
0
0
0
0
0
0
0
[ "Thanks for the tag. This Is expected as there is more work done to potentially return a `RangeIndex` instead of an `Index` but I'll double check once more if some of that work can be minimized" ]
2,165,096,741
57,711
TST: Add test for `grouby` after `dropna` agg `nunique` and `unique`
closed
2024-03-03T02:43:59
2024-03-05T01:09:48
2024-03-05T00:47:10
https://github.com/pandas-dev/pandas/pull/57711
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57711
https://github.com/pandas-dev/pandas/pull/57711
luke396
1
- [x] closes #42016 (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" ]
0
0
0
0
0
0
0
0
[ "Thanks @luke396 " ]
2,165,021,095
57,710
REF: Remove dynamic docstrings from option methods
closed
2024-03-02T23:09:36
2024-03-06T22:00:56
2024-03-06T22:00:53
https://github.com/pandas-dev/pandas/pull/57710
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57710
https://github.com/pandas-dev/pandas/pull/57710
mroeschke
2
xref https://github.com/pandas-dev/pandas/issues/57578#issuecomment-1960937283 These methods have complex docstrings in an attempt to display all option within the docstring. This makes these docstrings hard to automatically validate and [renders the internal implementation](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.describe_option.html#pandas.describe_option) in Sphinx. I think it's reasonable to link to the docs where all the options are listed instead. Additionally did some cleanups removing `silent` from some of these methods by instead catching warnings where needed
[ "Refactor" ]
0
0
0
0
0
0
0
0
[ "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57710/" ]
2,165,019,795
57,709
BUG: Boxplot does not apply colors set by Matplotlib rcParams for certain plot elements
open
2024-03-02T23:04:34
2025-07-15T20:43:51
null
https://github.com/pandas-dev/pandas/issues/57709
true
null
null
thetestspecimen
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. - [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 numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib as mpl df = pd.DataFrame(np.random.default_rng(12).random((10, 2))) with mpl.rc_context({'boxplot.boxprops.color': 'red', 'boxplot.whiskerprops.color': 'green', 'boxplot.capprops.color': 'orange', 'boxplot.medianprops.color': 'cyan', 'patch.facecolor': 'grey'}): df.plot.box(patch_artist=True) # OR df.plot(kind='box', patch_artist=True) plt.show() ``` ### Issue Description If the 'Reproducible Example' code is run it will result in the following: ![pandas-example](https://github.com/pandas-dev/pandas/assets/40262729/f37f4507-2715-4962-b4ec-d9446014093d) If run directly through Matplotlib like so: ```python import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib as mpl df = pd.DataFrame(np.random.default_rng(12).random((10, 2))) with mpl.rc_context({'boxplot.boxprops.color': 'red', 'boxplot.whiskerprops.color': 'green', 'boxplot.capprops.color': 'orange', 'boxplot.medianprops.color': 'cyan', 'patch.facecolor': 'grey'}): plt.boxplot(df, patch_artist=True) plt.show() ``` You end up with this: ![matplotlib-example](https://github.com/pandas-dev/pandas/assets/40262729/6f456b59-b8f9-48b1-b008-46091291660d) As you can see Pandas completely ignores the rcParams assignment, and sets it's own colours. I have only included in this example the exact elements (box, whiskers, caps, medians and box-face) that are ignored. It should also be noted that as the rcParams are ignored, Matplotlib stylesheets are also ignored if applied to these elements. As Pandas does this **only** for these specific elements in the boxplot, it can result in some terrible looking plots if someone uses a comprehensive set of rcParams (or stylesheet) that have a significantly different set of colours. ### A solution? I have looked into where this occurs, and all the relevant code resides in: https://github.com/pandas-dev/pandas/blob/main/pandas/plotting/_matplotlib/boxplot.py Specifically, methods `_get_colors()` and `_color_attrs(self)`. These two methods (among other bits of linked code) basically pick specific colours from the assigned colormap and apply them to the plot. I know what needs adjusting, and could put in a PR. However, due to the nature of rcParams being the "default" and hence having the lowest priority in terms of application, I see no way to adjust the code without changing the current default colours (i.e. blue, and a green median taken from the "tab10" colormap). That is why I am filing this 'bug', as I can see this change might be objectionable, and as such will require further discussion on the appropriate solution. The solution I am proposing, of using matplotlib rcParam defaults, would result in the following "default" plot: ![matplotlib-default](https://github.com/pandas-dev/pandas/assets/40262729/6d2af3ab-a99d-459c-84d5-1e072d2b8d94) My personal opinion is that this visual change is minor, and therefore should be implemented. I would also argue that accessibility is hindered by the current implementation (colour blindness being an example). ### Items to note While reviewing the code I noticed the following: 1. #40769 is not completely solved as it was only fixed for the method `plot.box` and not `boxplot` (the two methods use different code within `boxplot.py`) - see line 376 of `boxplot.py` for the hardcoded black value for the caps using the method `boxplot` `result = np.append(result, "k")` 2. the section of code refactored by #30346 does not distinguish between `edgecolor` and `facecolor` when `patch_artist` is set to `True`. This may or may not have been intentional, but should probably be separated out as it is the only reason `patch.facecolor` features this current bug report. ### Expected Behavior If colours are set in matplotlib rcParams (or stylesheets) by the user, they should be applied to the plot, not ignored. ### Installed Versions <details> commit : 69f03a39ecf654e23490cc6d2e103c5e06ccae18 python : 3.10.13.final.0 python-bits : 64 OS : Linux OS-release : 6.7.4-2-MANJARO Version : #1 SMP PREEMPT_DYNAMIC Sat Feb 10 09:41:20 UTC 2024 machine : x86_64 processor : byteorder : little LC_ALL : None LANG : en_GB.UTF-8 LOCALE : en_GB.UTF-8 pandas : 3.0.0.dev0+448.g69f03a39ec numpy : 1.26.4 pytz : 2024.1 dateutil : 2.9.0 setuptools : 69.1.1 pip : 24.0 Cython : 3.0.8 pytest : 8.0.2 hypothesis : 6.98.15 sphinx : 7.2.6 blosc : None feather : None xlsxwriter : 3.1.9 lxml.etree : 5.1.0 html5lib : 1.1 pymysql : 1.4.6 psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : 8.22.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.8 fastparquet : 2024.2.0 fsspec : 2024.2.0 gcsfs : 2024.2.0 matplotlib : 3.8.3 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pyarrow : 15.0.0 pyreadstat : 1.2.6 python-calamine : None pyxlsb : 1.0.10 s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.27 tables : 3.9.2 tabulate : 0.9.0 xarray : 2024.2.0 xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Visualization", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "I'm interested in taking the bug once it is triaged, if possible as part of a university project.", "> I'm interested in taking the bug once it is triaged, if possible as part of a university project.\r\n\r\nAs I mentioned in the bug report, I have already looked into the problem and have a potential solution ready and waiting in the form of a pull request (pending discussion and approval with the Pandas devs of course). \r\n\r\nIn my opinion, it might be better for the Pandas project to concentrate your efforts on a bug that is open, but has no fix offered? There are currently 3.6k issues open, so you should be spoilt for choice.\r\n\r\n\r\n\r\n\r\n" ]
2,164,955,591
57,708
REF: Avoid importing xlrd
closed
2024-03-02T20:12:22
2024-03-05T00:32:15
2024-03-05T00:29:17
https://github.com/pandas-dev/pandas/pull/57708
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57708
https://github.com/pandas-dev/pandas/pull/57708
rhshadrach
4
- [x] closes #56692 (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. Not sure how I'd add a test here.
[ "Refactor", "IO Excel", "Dependencies" ]
0
0
0
0
0
0
0
0
[ "Could check sys.modules for presence of xlrd?", "> Could check sys.modules for presence of xlrd?\r\n\r\nTrue; since that's global I think it'd have to check it in a subprocess. It seems to me a bit of an odd thing to test - unless we think we should have more testing that we don't import an optional dependency if it's not used more generally. Are we okay foregoing a test here?", "Fine by me\r\n\r\nOn Mon, Mar 4, 2024 at 1:55 PM Richard Shadrach ***@***.***>\r\nwrote:\r\n\r\n> Could check sys.modules for presence of xlrd?\r\n>\r\n> True; since that's global I think it'd have to check it in a subprocess.\r\n> It seems to me a bit of an odd thing to test - unless we think we should\r\n> have more testing that we don't import an optional dependency if it's not\r\n> used more generally. Are we okay foregoing a test here?\r\n>\r\n> —\r\n> Reply to this email directly, view it on GitHub\r\n> <https://github.com/pandas-dev/pandas/pull/57708#issuecomment-1977529179>,\r\n> or unsubscribe\r\n> <https://github.com/notifications/unsubscribe-auth/AB5UM6HDBJRPX334VW46JMLYWTUTPAVCNFSM6AAAAABEDK5ATGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZXGUZDSMJXHE>\r\n> .\r\n> You are receiving this because you commented.Message ID:\r\n> ***@***.***>\r\n>\r\n", "Thanks @rhshadrach " ]
2,164,949,220
57,707
Backport PR #57668 on branch 2.2.x (CLN: More numpy 2 stuff)
closed
2024-03-02T19:52:37
2024-03-03T12:54:00
2024-03-03T12:54:00
https://github.com/pandas-dev/pandas/pull/57707
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57707
https://github.com/pandas-dev/pandas/pull/57707
meeseeksmachine
0
Backport PR #57668: CLN: More numpy 2 stuff
[ "Compat", "Clean" ]
0
0
0
0
0
0
0
0
[]
2,164,921,519
57,706
BUG: groupby.agg should always agg
open
2024-03-02T18:33:27
2025-04-16T08:33:44
null
https://github.com/pandas-dev/pandas/pull/57706
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57706
https://github.com/pandas-dev/pandas/pull/57706
rhshadrach
6
- [x] closes #52362 - [x] closes #39920 - [x] closes #39436 - [x] closes #39169 - [x] closes #28570 - [x] closes #26611 Built on top of #57671; the diff should get better once that's merged. Still plan on splitting part of this up as a precursor (and perhaps multiple). For the closed issues above, tests here still likely need to be added. The goal here is to make groupby.agg more consistently handle UDFs. Currently: - We sometimes raise if a UDF returns a NumPy ndarray - We sometimes treat non-scalars as transforms - We sometimes fail (non-purposefully) on non-scalars - We sometimes pass the entire group to the UDF rather than column-by-column My opinion is that we should treat all UDFs as reducers, regardless of what they return. Some alternatives: 1. If we detect something as being a non-scalar, try treating it as a transform 2. Raise on anything detected as being a non-scalar For 1, we will sometimes guess wrong, and transforming isn't something we should be doing in a method called `agg` anyways. For 2, we are restricting what I think are valid use cases for aggregation, e.g. `gb.agg(np.array)` or `gb.agg(list)`. In implementing this, I ran into two issues: - `_aggregate_frame` fails if non-scalars are returned by the UDF, and also passes all of the selected columns as a DataFrame to the UDF. This is called when there is a single grouping and args or kwargs are provided, or when there is a single grouping and passing the UDF each column individually fails with a ValueError("No objects to concatenate"). This does not seem possible to fix, would be hard to deprecate (could add a new argument or use a `future` option?), and is bad enough behavior that it seems to me we should just rip the band aid here for 3.0. - `Resampler.apply` is an alias for `Resample.agg`, and we do not want to impact `Resampler.apply` with these changes. For this, I kept the old paths through groupby specifically for resampler and plan to properly deprecate the current method and implement apply (by calling groupby's apply) as part of 3.x development. (Ref: #38463)
[ "Enhancement", "Groupby", "API Design", "Needs Discussion", "Apply" ]
0
0
0
0
0
0
0
0
[ "I think this is ready for review. Assuming the direction this is moving us is good, still need to decide if we are okay with this being a breaking change in 3.0 (my preference) or if it should be deprecated. If we do go the deprecation route, it will be noisy (many cases where results will be the same but we can't tell so need to warn). The only way I see a deprecation working is if we add an option, e.g. `future_groupby_agg` so that users can opt in to the new implementation.\r\n\r\ncc @jorisvandenbossche @MarcoGorelli @Dr-Irv @mroeschke for any thoughts.", "I could generally be OK making this a \"breaking bug change\" for 3.0. Just 2 points:\r\n\r\n1. Is `DataFrame.agg` already strict like this?\r\n2. For `Raise on anything detected as being a non-scalar`, I would be open to still allowing `.agg` to store a non-scalar, i.e. nested value, as a result element and return `dtype=object`. But these values should never expand the dimensions of the result when using `agg` ", "I'm not going to review the whole code change - beyond what I understand about how this all works, but I think the example I wrote here should be in the tests:\r\nhttps://github.com/pandas-dev/pandas/issues/33242#issuecomment-706734773\r\n", "@mroeschke \r\n\r\n> 1. Is `DataFrame.agg` already strict like this?\r\n\r\nGreat question - unfortunately the answer is no. We use `DataFrame.apply` under the hood. Perhaps if we are going to do this with groupby, we should also do it across the board. That would make me lean more toward introducing something like a `future.agg` option.\r\n\r\n> 2\\. For `Raise on anything detected as being a non-scalar`, I would be open to still allowing `.agg` to store a non-scalar, i.e. nested value, as a result element and return `dtype=object`. But these values should never expand the dimensions of the result when using `agg`\r\n\r\nAgreed. I believe that's the case here for a UDF, but not strings (e.g. `cumsum`). This is #44845 - but I'd like to focus on UDFs here and work on string arguments separately.\r\n\r\n@Dr-Irv \r\n\r\n> I'm not going to review the whole code change - beyond what I understand about how this all works, but I think the example I wrote here should be in the tests:\r\n\r\nCertainly - I added this as `test_unused_kwargs`. In that test, we use `np.sum(np.sum(data))`. This way works both on column and frame inputs, and would raise if we pass a frame instead of column-by-column. Is this sufficient?", "> Certainly - I added this as `test_unused_kwargs`. In that test, we use `np.sum(np.sum(data))`. This way works both on column and frame inputs, and would raise if we pass a frame instead of column-by-column. Is this sufficient?\r\n\r\nI'm not sure. In the example I created, you had 2 functions, one with 1 argument, the other with 2 arguments, and what was being passed to those 2 functions was different because of the number of arguments. I don't see how the test you created confirms that `Series` are passed independent of the function declaration. \r\n\r\nSo maybe you should have a test like this that addresses the particular issue in #33242 :\r\n```python\r\ndef twoargs(x, y):\r\n assert isinstance(x, pd.Series)\r\n return x.sum()\r\n \r\ndef test_two_args(self):\r\n df = pd.DataFrame({'a': [1,2,3,4,5,6],\r\n 'b': [1,1,0,1,1,0],\r\n 'c': ['x','x','x','z','z','z'],\r\n 'd': ['s','s','s','d','d','d']})\r\n df.groupby('c')[['a', 'b']].agg(twoargs, 0)\r\n```\r\n", "> I don't see how the test you created confirms that `Series` are passed independent of the function declaration.\r\n\r\nWe don't ever inspect the UDF to see what arguments it can take - our logic branches on whether additional arguments are passed in the call to `agg`: `.agg(func, 0)` vs `.agg(func)` previously resulted in two different paths, one which passed the DataFrame and one which passed each Seriers.\r\n\r\nStill, no opposition to an additional test here. Will add. " ]
2,164,904,171
57,705
Cython guard against [c|m|re]alloc failures
closed
2024-03-02T17:42:22
2024-03-21T23:20:55
2024-03-20T17:00:00
https://github.com/pandas-dev/pandas/pull/57705
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57705
https://github.com/pandas-dev/pandas/pull/57705
WillAyd
1
Not sure if these are testable but in the case of the system being exhausted for resources these should explicitly throw a MemoryError instead of allow undefined behavior @MarcoGorelli don't know how difficult it would be but would be cool to have the cython linter catch uses of any low-level allocation function and ensure that a guard against NULL comes thereafter. The only exception I could think of to that rule is if you are immediately returning the result of an malloc and expect the caller to guard against NULL, but we don't have any instances of that in our code base (may also not matter for Cython)
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @WillAyd " ]
2,164,901,430
57,704
CLN: Hashtable rename struct members
closed
2024-03-02T17:34:06
2024-03-20T17:52:49
2024-03-20T17:48:17
https://github.com/pandas-dev/pandas/pull/57704
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57704
https://github.com/pandas-dev/pandas/pull/57704
WillAyd
3
Should help with readability
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "Seems like there is a conflict now, if you want to have a look...", "One more conflict here otherwise LGTM", "Thanks @WillAyd " ]
2,164,884,928
57,703
Nanosecond fixed precision of DatetimeIndex with time zone information, Fix #53473
closed
2024-03-02T16:45:54
2024-04-15T17:25:26
2024-04-15T17:25:25
https://github.com/pandas-dev/pandas/pull/57703
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57703
https://github.com/pandas-dev/pandas/pull/57703
MarcusJak
3
The expected behaviour is now correct from issue #53473 The out->picoseond value wasn't set which ended with a Json error regarding the ns calculations. - [x] closes #53473 - [ ] [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 JSON", "Stale" ]
0
0
0
0
0
0
0
0
[ "Hi @WillAyd could you please check the new fixes, we would appreciate that :)", "This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.", "Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen." ]
2,164,619,084
57,702
BUG: inconsisntent construction results between `pd.array` and `pd.Series` for dtype=str
open
2024-03-02T05:56:14
2024-03-29T21:15:02
null
https://github.com/pandas-dev/pandas/issues/57702
true
null
null
koizumihiroo
9
### 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.array([1, None], dtype=str) # <NumpyExtensionArray> # ['1', 'None'] # Length: 2, dtype: str128 pd.Series([1, None], dtype=str).array # <NumpyExtensionArray> # ['1', None] # Length: 2, dtype: object pd.DataFrame([1, None], dtype=str)[0].array # <NumpyExtensionArray> # ['1', None] # Length: 2, dtype: object ``` ### Issue Description While pd.Series returns object dtype when including `None` value in data for `dtype=str`, pd.array convert it to `"None"` string value. I am not sure this is intended or already discussed, but seems curious. As investigating in construction process, `pd.array` pass dtype as is (str) but `pd.Sereis` call (via `lib.ensure_string_array`) dtype as "object" ### using `pd.array` ```python # https://github.com/pandas-dev/pandas/blob/v2.2.1/pandas/core/arrays/numpy_.py#L127 result = np.asarray(scalars, dtype=dtype) ``` ### using `pd.Sereis` ```python # https://github.com/pandas-dev/pandas/blob/v2.2.1/pandas/core/construction.py#L800-L802 # lib.ensure_string_array(arr, convert_na_value=False, copy=copy).reshape(shape) # https://github.com/pandas-dev/pandas/blob/v2.2.1/pandas/_libs/lib.pyx#L766 result = np.asarray(arr, dtype="object") ``` ### Expected Behavior Although there might be historical reasons behind this divergent behavior, striving for consistency between pd.array and pd.Series for dtype=str would be more intuitive. ### Installed Versions <details> /tmp/pandas-report/.venv/lib/python3.11/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.") INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.6.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 : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.1 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 65.5.0 pip : 23.2.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 : 3.1.3 IPython : 8.22.1 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 : 2024.2.0 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 : 2.0.27 tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "I also confirmed the issue on the main branch version '3.0.0.dev0+480.gc71244ad21' with NumPy version '1.26.4' (installing NumPy-2.0.0.dev0 with Pandas-3.0.0.dev0+480.gc71244ad21 resulted in pandas import error without pyarrow installation).\r\n", "take", "here's what i know, coming from a beginner in contributing to open-source, np.asarray is where the change/cast happens in the array, so we can't change anything in there. The only thing i can think of now is trying to cast each element and then create the numpy array with different parameters.", "and should a cast fail, the element should be kept as is", "but when it comes to a None, it can be casted to some dtypes (like string in the example above), that's why its possible to obtain the result with a 'None' ", "i have developed a temporary solution but possibly not what one might look for, i separate the None's from the rest of the data and call np.asarray with dtype=<given_dtype> for those values, then i also generate an array for the None's by using np.asarray with dtype=\"object\" only if there are None's in the given set. If there are None's the final output will state the dtype as object like in both pd.Series(...).array and pd.Dataframe(...)[0].array", "I have developed now a solution that could be the one… I’m moving on the testing phase before making a pull request", "i have now created a new test that will fail with the current version of the https://github.com/pandas-dev/pandas/blob/v2.2.1/pandas/core/arrays/numpy_.py#L116 of the _from_sequence classmethod and will pass under my solution but its compromising 3 other tests, working on it...", "I have addapted my solution for those compromised tests, and here's my veredict:\r\ni had trouble passing the test where shared memory is asserted (https://github.com/pandas-dev/pandas/blob/main/pandas/tests/arrays/test_array.py#L269), after adapting, this is the result: for the example tested, there is no problem, but in order to process None correctly, shared memory will not be possible because of the separating of the none's from the rest of the values" ]
2,164,305,521
57,701
Less Heap Usage in Hashtable
closed
2024-03-01T22:43:53
2024-03-12T02:31:20
2024-03-05T00:45:30
https://github.com/pandas-dev/pandas/pull/57701
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57701
https://github.com/pandas-dev/pandas/pull/57701
WillAyd
1
null
[ "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @WillAyd " ]
2,164,292,517
57,700
DEPR: depreecate uppercase units 'MIN', 'MS', 'US', 'NS' in Timedelta and 'to_timedelta'
closed
2024-03-01T22:31:20
2024-06-27T11:55:21
2024-06-27T11:55:21
https://github.com/pandas-dev/pandas/pull/57700
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57700
https://github.com/pandas-dev/pandas/pull/57700
natmokval
2
Deprecated uppercase strings `“MIN”, “MS”, “US”, “NS”` denoting units from the class `Timedelta` and the method `to_timedelta`. The reason: for period/offsets these strings are already deprecated. Instead of the uppercase strings we use lowercase: `“min”, “ms”, “us”, “ns”`.
[ "Timedelta", "Deprecate", "Stale" ]
0
0
0
0
0
0
0
0
[ "This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.", "closed via #59051 " ]
2,164,288,391
57,699
DEPR: remove deprecated freqs/abbrevs 'A', 'A-DEC', 'A-JAN', etc.
closed
2024-03-01T22:26:56
2024-03-08T18:30:33
2024-03-08T18:30:25
https://github.com/pandas-dev/pandas/pull/57699
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57699
https://github.com/pandas-dev/pandas/pull/57699
natmokval
2
xref #55252 remove deprecated string 'A', 'A-DEC', etc. denoting timedelta abbreviations and timeseries frequencies
[ "Deprecate" ]
0
0
0
0
0
0
0
0
[ "Thanks @MarcoGorelli for reviewing this PR.", "Thanks @natmokval " ]
2,164,178,631
57,698
ENH: Adding `pipe` operations to `pandas.api.typing.Rolling` instances
closed
2024-03-01T21:07:38
2024-04-23T18:58:32
2024-04-23T18:58:32
https://github.com/pandas-dev/pandas/pull/57698
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57698
https://github.com/pandas-dev/pandas/pull/57698
jrmylow
1
- [ ] closes #57076 (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 for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen." ]
2,164,066,101
57,697
BUG: Fix empty MultiIndex DataFrame xlsx export
closed
2024-03-01T19:46:53
2024-09-16T10:44:17
2024-03-02T12:04:19
https://github.com/pandas-dev/pandas/pull/57697
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57697
https://github.com/pandas-dev/pandas/pull/57697
speleo3
3
Fix Excel xlsx export of empty (zero rows) DataFrame with MultiIndex on both axes. - [x] closes #57696 - [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.
[ "Bug", "IO Excel", "MultiIndex" ]
0
0
0
0
0
0
0
0
[ "Thanks @speleo3 - nice fix!", "Thanks a lot for fixing this. I'm running into this exact issue at work. Since 3.0.0 hasn't been released yet, is there a workaround in the meantime?", "My attempt:\r\n\r\n```py\r\nif df.empty and not df.columns:\r\n df.columns = []\r\n```" ]
2,163,965,930
57,696
BUG: Error when exporting empty DataFrame with MultiIndex on both axes to xlsx file
closed
2024-03-01T18:31:08
2024-03-02T12:04:20
2024-03-02T12:04:20
https://github.com/pandas-dev/pandas/issues/57696
true
null
null
speleo3
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 import pandas as pd df = pd.DataFrame( data=[], index=pd.MultiIndex.from_tuples([], names=[0, 1]), columns=pd.MultiIndex.from_tuples([("A", "B")]), ) df.to_excel("tmp.xlsx") ``` ### Issue Description The given example tries to write an empty dataframe with multiindex rows and columns to an Excel xlsx file. Observed exception: ``` Traceback (most recent call last): File "example.py", line 7, in <module> df.to_excel("tmp.xlsx") File ".../lib/python3.10/site-packages/pandas/core/generic.py", line 2258, in to_excel formatter.write( File ".../lib/python3.10/site-packages/pandas/io/formats/excel.py", line 944, in write writer._write_cells( File ".../lib/python3.10/site-packages/pandas/io/excel/_xlsxwriter.py", line 261, in _write_cells for cell in cells: File ".../lib/python3.10/site-packages/pandas/io/formats/excel.py", line 881, in get_formatted_cells for cell in itertools.chain(self._format_header(), self._format_body()): File ".../lib/python3.10/site-packages/pandas/io/formats/excel.py", line 626, in _format_header_mi coloffset = len(self.df.index[0]) - 1 File ".../lib/python3.10/site-packages/pandas/core/indexes/multi.py", line 2140, in __getitem__ if level_codes[key] == -1: IndexError: index 0 is out of bounds for axis 0 with size 0 ``` This bug is almost identical to https://github.com/pandas-dev/pandas/issues/46873 but for the case with multiindex columns. ### Expected Behavior Excel file written. No exception. ### Installed Versions <details> <pre> INSTALLED VERSIONS ------------------ commit : ab2980ba52ae24db72765b3c4ae1d33ac8fad3f5 python : 3.10.13.final.0 python-bits : 64 OS : Linux OS-release : 6.7.6-arch1-1 Version : #1 SMP PREEMPT_DYNAMIC Fri, 23 Feb 2024 16:31:48 +0000 machine : x86_64 processor : byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 3.0.0.dev0+451.gab2980ba52.dirty numpy : 1.26.4 pytz : 2024.1 dateutil : 2.9.0 setuptools : 69.1.1 pip : 24.0 Cython : 3.0.8 pytest : 8.0.2 hypothesis : 6.98.15 sphinx : 7.2.6 blosc : None feather : None xlsxwriter : 3.1.9 lxml.etree : 5.1.0 html5lib : 1.1 pymysql : 1.4.6 psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : 8.22.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.8 fastparquet : 2024.2.0 fsspec : 2024.2.0 gcsfs : 2024.2.0 matplotlib : 3.8.3 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pyarrow : 15.0.0 pyreadstat : 1.2.6 python-calamine : None pyxlsb : 1.0.10 s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.27 tables : 3.9.2 tabulate : 0.9.0 xarray : 2024.2.0 xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2024.1 qtpy : None pyqt5 : None </pre> </details>
[ "Bug", "IO Excel", "MultiIndex" ]
0
0
0
0
0
0
0
0
[]
2,163,958,056
57,695
Use memcpy / realloc more effectively in hashtable
closed
2024-03-01T18:25:14
2024-03-21T18:29:30
2024-03-21T18:29:27
https://github.com/pandas-dev/pandas/pull/57695
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57695
https://github.com/pandas-dev/pandas/pull/57695
WillAyd
2
null
[ "Performance" ]
0
0
0
0
0
0
0
0
[ "Hashing benchmarks:\r\n\r\n```\r\n| Change | Before [710720e6] <main> | After [cfa5b85f] <memcpy-extend> | Ratio | Benchmark (Parameter) |\r\n|----------|----------------------------|------------------------------------|---------|----------------------------------------------------------------------------------------------|\r\n| - | 1.12±0.2ms | 901±40μs | 0.8 | hash_functions.NumericSeriesIndexingShuffled.time_loc_slice(<class 'numpy.uint64'>, 1000000) |\r\n| - | 1.26±0.1ms | 893±30μs | 0.71 | hash_functions.NumericSeriesIndexingShuffled.time_loc_slice(<class 'numpy.int64'>, 1000000) |\r\n\r\nSOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.\r\nPERFORMANCE INCREASED.\r\n```\r\n\r\nalgorithms:\r\n\r\n```\r\n| Change | Before [710720e6] <main> | After [cfa5b85f] <memcpy-extend> | Ratio | Benchmark (Parameter) |\r\n|----------|----------------------------|------------------------------------|---------|-----------------------------------------------------------------------------|\r\n| + | 2.11±0.04μs | 2.34±0.1μs | 1.11 | algorithms.Duplicated.time_duplicated(True, 'last', 'duration[s][pyarrow]') |\r\n| - | 5.81±0.2ms | 5.28±0.08ms | 0.91 | algorithms.Hashing.time_series_string |\r\n| - | 2.27±0.2ms | 1.89±0.04ms | 0.83 | algorithms.Quantile.time_quantile(1, 'linear', 'float64') |\r\n| - | 1.09±0.04ms | 850±20μs | 0.78 | algorithms.Quantile.time_quantile(1, 'nearest', 'uint64') |\r\n| - | 1.89±0.2ms | 1.31±0.06ms | 0.7 | algorithms.Quantile.time_quantile(0, 'midpoint', 'uint64') |\r\n\r\nSOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.\r\nPERFORMANCE DECREASED.\r\n```\r\n\r\ngroupby:\r\n\r\n```\r\n| Change | Before [710720e6] <main> | After [cfa5b85f] <memcpy-extend> | Ratio | Benchmark (Parameter) |\r\n|----------|----------------------------|------------------------------------|---------|-----------------------------------------------------------------------------------------|\r\n| + | 28.5±0.1ms | 31.7±1ms | 1.11 | groupby.GroupByCythonAggEaDtypes.time_frame_agg('Float64', 'var') |\r\n| - | 29.0±2ms | 26.4±0.4ms | 0.91 | groupby.GroupByCythonAggEaDtypes.time_frame_agg('Int32', 'last') |\r\n| - | 85.1±10μs | 77.1±3μs | 0.91 | groupby.GroupByMethods.time_dtype_as_group('int16', 'nunique', 'direct', 1, 'cython') |\r\n| - | 24.9±0.7μs | 22.6±0.5μs | 0.91 | groupby.GroupByMethods.time_dtype_as_group('uint', 'bfill', 'direct', 1, 'cython') |\r\n| - | 35.8±3μs | 32.1±0.2μs | 0.9 | groupby.GroupByMethods.time_dtype_as_group('int', 'std', 'direct', 1, 'cython') |\r\n| - | 37.3±1μs | 33.7±2μs | 0.9 | groupby.GroupByMethods.time_dtype_as_group('uint', 'std', 'direct', 1, 'cython') |\r\n| - | 1.33±0.05ms | 1.19±0.02ms | 0.9 | groupby.MultipleCategories.time_groupby_transform |\r\n| - | 16.9±0.2ms | 15.1±0.2ms | 0.89 | groupby.GroupByMethods.time_dtype_as_group('uint', 'describe', 'direct', 1, 'cython') |\r\n| - | 73.9±1μs | 66.0±0.6μs | 0.89 | groupby.GroupByMethods.time_dtype_as_group('uint', 'diff', 'direct', 1, 'cython') |\r\n| - | 398±5μs | 355±2μs | 0.89 | groupby.GroupByMethods.time_dtype_as_group('uint', 'pct_change', 'direct', 1, 'cython') |\r\n| - | 4.54±0.2ms | 4.01±0.1ms | 0.88 | groupby.Nth.time_groupby_nth_all('datetime') |\r\n| - | 36.0±2μs | 30.9±1μs | 0.86 | groupby.GroupByMethods.time_dtype_as_group('int16', 'first', 'direct', 1, 'cython') |\r\n| - | 9.09±0.5ms | 7.81±0.2ms | 0.86 | groupby.Nth.time_series_nth_all('datetime') |\r\n| - | 618±100μs | 394±30μs | 0.64 | groupby.GroupByMethods.time_dtype_as_group('float', 'sum', 'direct', 1, 'numba') |\r\n\r\nSOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.\r\nPERFORMANCE DECREASED.\r\n```\r\n\r\nNot why there are some regressions with algorithms - those may just be flaky tests. I do get different results every time I run the asvs there", "Alright sorry for letting this go stale for a while but all green and posted updated benchmarks. @mroeschke " ]
2,163,583,225
57,694
Failing benchmarks - About 3000 asv benchmark tests fail out of 7545
closed
2024-03-01T14:56:57
2024-03-02T18:59:12
2024-03-02T18:59:12
https://github.com/pandas-dev/pandas/issues/57694
true
null
null
DeaMariaLeon
8
Is it normal that out of 7545 benchmark tests, 3014 fail? (these numbers are for Cython 3.0). It's more or less the same with 3.05. For "test" I mean a benchmark with one combination of its parameters. For example this would be 1 test: "ctors.SeriesConstructors.time_series_constructor('<function gen_of_str>', 'True', "'float'")". All the failing tests are seen as blank [here](https://asv-runner.github.io/asv-collection/pandas/#summarylist?python=3.10&numpy=%5Bnone%5D&Cython=3.0.0&xlwt=%5Bnone%5D&meson=&meson-python=&python-build=&sort=1&dir=asc). Is the command bellow being done somewhere in the workflow? As you might know, it's supposed to be done after a benchmark is updated/changed: ``` [asv update](https://asv.readthedocs.io/en/v0.6.1/commands.html?highlight=asv%20publish#id14) usage: asv update [-h] [--verbose] [--config CONFIG] [--version] Update the results and config files to the current version options: -h, --help show this help message and exit --verbose, -v Increase verbosity --config CONFIG Benchmark configuration file --version Print program version ``` For "fail" I mean as in getting `NaN` or `null` as result. From asv docs: ``` result:(param-list) contains the summarized result value(s) of the benchmark. The values are float, NaN or null. The values are either numbers indicating result from successful run, null indicating a failed benchmark, or NaN indicating a benchmark explicitly skipped by the benchmark suite. ```
[ "Benchmark" ]
0
0
0
0
0
0
0
0
[ "There should be a traceback if you do ``--show-stderr``. Usually NaN would mean that there was an error running the benchmarks.\r\n\r\nThere seems to be data recorded here, though https://github.com/asv-runner/asv-collection/blob/master/pandas/graphs/Cython-3.0.0/arch-x86_64/branch-main/cpu-Intel(R)%20Core(TM)%20i7-4980HQ%20CPU%20%40%202.80GHz/jinja2/machine-asv-runner/matplotlib/meson/meson-python/numba/numexpr/numpy-null/odfpy/openpyxl/os-Linux%203.13.0-116-generic/pyarrow/pytables/python-3.10/python-build/ram-501692/scipy/sqlalchemy/xlrd/xlsxwriter/xlwt-null/ctors.SeriesConstructors.time_series_constructor.json\r\n\r\nMaybe it's a visual bug?", "@lithomas1 Thanks, but it's not a visual bug. On the link you sent, some of the results are \"null\", meaning it's a failed benchmark result. If you see the results in the middle:\r\n\r\n![Screenshot 2024-03-01 at 16 59 10](https://github.com/pandas-dev/pandas/assets/11835246/f9093ef6-00bf-4bd3-98af-73f8faa52e82)\r\n\r\nPlus I see the same with conbench, and looking at the .json files generated by asv. \r\nI think that benchmarks are being updated, but asv is not being \"told\" to update (the command I sent above: `asv update`). Look:\r\n```\r\n params: contains a copy of the parameter values of the benchmark, as described above. If the user has modified the benchmark after the benchmark was run, these may differ from the current values. \r\n```", "For NaN I think this is expected. As far as I know, you can only use a full cartesian product when parametrizing a benchmark with multiple parameters. In order to exclude certain (invalid) combinations of parameters, we `raise NotImplementedError` in the benchmarks. I believe this will result in a NaN.\r\n\r\nHow many `null` vs `NaN` do you see?", "Thanks @rhshadrach. The results we need are all `NaN`. Some others are `null` but are not used.\r\n\r\nThe last thing is, do you perform the \"asv update\" command or is it done somewhere?\r\nIf you don't know never mind. I ask just because is in asv's documentation but if that's not a problem I'm good.\r\n\r\n\r\n\r\n", "No - I do not currently.", "You have this on your [code](https://github.com/rhshadrach/asv-watcher/blob/10cec8096b5bb1d1ef7ef4b320bf8b2db482c98b/asv_watcher/_core/update_data.py#L19): \r\n```\r\n# TODO: Why does this happen?\r\n# print(benchmark, \"has no data. Skipping.\")\r\n```\r\n\r\nI have that when the result is `nan`. And I think you have another issue with the name of the benchmark not being found. It happened to me when the file \"benchmarks.json\" was not updated. \r\n\r\nOtherwise, sorry for the noise.\r\n", "Thanks! I had been wanting to spend some time investigating that for months now, and you just saved me the hassle!\r\n\r\n> And I think you have another issue with the name of the benchmark not being found. It happened to me when the file \"benchmarks.json\" was not updated.\r\n\r\nI see - I don't think I understood what update was doing, but it sounds like it will take old benchmark results and update them with the new benchmark suite (if it has changed). This will be very useful!", "I'm glad to hear that! - It [looks](https://github.com/airspeed-velocity/asv/releases#:~:text=you%20to%20run-,asv%20update,-once%20after%20upgrading) that sometimes that update is needed and sometimes it's not, depending how you run asv. \r\nAnd from the [docs](https://asv.readthedocs.io/en/v0.6.1/dev.html?highlight=version#benchmark-suite-layout-and-file-formats:~:text=params%3A%20contains%20a%20copy%20of%20the%20parameter%20values%20of%20the%20benchmark%2C%20as%20described%20above.%20If%20the%20user%20has%20modified%20the%20benchmark%20after%20the%20benchmark%20was%20run%2C%20these%20may%20differ%20from%20the%20current%20values.) it's clear that things can get out of sync. \r\n\r\nClosing this then, thanks. :-) " ]
2,163,541,000
57,693
TST: Some Stata test datasets do not match the expected version
closed
2024-03-01T14:32:40
2024-04-09T16:43:20
2024-04-09T16:43:20
https://github.com/pandas-dev/pandas/issues/57693
true
null
null
cmjcharlton
0
A few of the Stata datasets used for testing are not in the format implied by their file names: - [stata4_114.dta](https://github.com/pandas-dev/pandas/blob/ab2980ba52ae24db72765b3c4ae1d33ac8fad3f5/pandas/tests/io/data/stata/stata4_114.dta) appears to actually be saved in 115 format. - [stata9_115.dta](https://github.com/pandas-dev/pandas/blob/ab2980ba52ae24db72765b3c4ae1d33ac8fad3f5/pandas/tests/io/data/stata/stata9_115.dta) appears to actually be saved in 117 format - [stata10_115.dta](https://github.com/pandas-dev/pandas/blob/ab2980ba52ae24db72765b3c4ae1d33ac8fad3f5/pandas/tests/io/data/stata/stata10_115.dta) appears to actually be saved in 117 format This may result in reduced test coverage for the expected versions.
[]
0
0
0
0
0
0
0
0
[]
2,163,455,342
57,692
Backport PR #57689 on branch 2.2.x (CI: fix ci (calamine typing))
closed
2024-03-01T13:47:28
2024-03-01T15:36:48
2024-03-01T15:36:48
https://github.com/pandas-dev/pandas/pull/57692
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57692
https://github.com/pandas-dev/pandas/pull/57692
MarcoGorelli
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.
[ "CI", "Typing" ]
0
0
0
0
0
0
0
0
[]
2,163,397,587
57,691
ENH: Be able to set dtype before creating a new column
closed
2024-03-01T13:19:54
2024-03-16T14:26:17
2024-03-16T14:26:17
https://github.com/pandas-dev/pandas/issues/57691
true
null
null
Chuck321123
4
### Feature Type - [X] Adding new functionality to pandas - [X] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description So one can do ``` df["New_Col"] = 0 df["New_Col"] = df["New_Col"].astype("int8") ``` But its not possible to do ``` df["New_Col"] = 0.astype("int8") ``` Would be nice to find a solution so one can set dtype before creating a new column. ### Feature Description See problem descripion ### Alternative Solutions Se problem description ### Additional Context _No response_
[ "Enhancement", "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "You could do:\r\n\r\n` df[\"New_Col\"] = np.int8(0)`\r\n\r\nNot sure if there's a datatype that using a typed scalar wouldn't work for.", "You can also use pd.array for other dtypes, e.g. \r\n\r\n df[\"New_Col\"] = pd.array([0] * len(df), dtype=\"Int32\")\r\n\r\n If you're concerned with creating a large Python list, you can also use NumPy here:\r\n\r\n df[\"New_Col\"] = pd.array(np.zeros(len(df), dtype=\"int8\"), dtype=\"Int32\")", "You can use np.array for all data types\r\n`df['New_Col'] = np.array([0]).astype(\"int8\")`", "> You can use np.array for all data types\r\ndf['New_Col'] = np.array([0]).astype(\"int8\")\r\n\r\nNo you can't, that's incorrect for ea arrays\r\n\r\nBut agree with @rhshadrach, you can do this with pd.array" ]
2,163,343,253
57,690
BUG: Groupby followed by calculations like rolling, ewm, expanding should not duplicate the group keys index
closed
2024-03-01T12:51:42
2024-03-01T23:02:52
2024-03-01T22:59:25
https://github.com/pandas-dev/pandas/issues/57690
true
null
null
furechan
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. - [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 io import pandas as pd DATA = """ ticker,date,price,volume AAA,2021-01-01,10.0,1000 AAA,2021-01-02,11.0,1000 AAA,2021-01-03,12.0,1000 AAA,2021-01-04,11.0,1000 BBB,2021-01-01,20.0,1000 BBB,2021-01-02,21.0,1000 BBB,2021-01-03,22.0,1000 BBB,2021-01-04,21.0,1000 """ f = io.StringIO(DATA) df = pd.read_csv(f, parse_dates=['date'], index_col=[0, 1]) df.price.groupby("ticker").rolling(2).mean() ``` ### Issue Description The result series has a duplicate index column 'ticker' as in ["ticker, "ticker", "date"] ### Expected Behavior Some calculations like `shift`, `pct_change`, etc can be applied to a series groupby and they will not change the resulting index. This makes sense because these functions are "one-to-one", they keep the series index intact. However other calculations like `rolling`, `ewm`, `expanding` which are also one-to-one, introduce a duplicate index when applied to a groupby. As a side note, this problem is already addressed for the `apply` method with the `group_keys=False` option. There is also an `as_index=False` option at the DataFrame level that seems to fix the problem, but it is available only at DataFrame level. It would make sense that `rolling`, `ewm`, `expanding` behave the same way as `shift`, `pct_change`, etc. Short of changing the behavior there should be an option like `as_index=False` or `group_keys=False` to fix the duplicate index when working with series. Thanks ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.9.18.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 : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.1 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 58.1.0 pip : 24.0 Cython : None pytest : 8.0.1 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 5.1.0 html5lib : 1.1 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 : None gcsfs : None matplotlib : 3.8.3 numba : 0.59.0 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 : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "API Design", "Duplicate Report", "Window" ]
0
0
0
0
0
0
0
0
[ "Related: #51751 and #36507", "It seems to me this issue is captured by the two I linked above, would you agree @furechan?", "Hi @rhshadrach,\r\n\r\nI agree that #51751 seems to be pointing to the same issue! rolling should be a transform in the same way that shift, pct_change are. The second issue #36507 is only a partial work around because from my experience using `as_index=False` does not add group keys to the index but it still adds them as data columns. If there had to be a work around, I would say the most logical would be to extend `group_keys=False` to rolling etc ...\r\n\r\nThank you", "`group_keys` was added specifically to give users some flexibility with `apply`. I would be very hesitant to expanding it to other methods, especially because it is very similar to `as_index`.\r\n\r\nClosing as a duplicate of #51751." ]
2,163,276,128
57,689
CI: fix ci (calamine typing)
closed
2024-03-01T12:14:35
2024-03-01T13:47:52
2024-03-01T13:42:31
https://github.com/pandas-dev/pandas/pull/57689
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57689
https://github.com/pandas-dev/pandas/pull/57689
MarcoGorelli
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. new calamine release is typed 🥳
[ "CI", "Typing" ]
0
0
0
0
0
0
0
0
[ "self-merging to fix ci", "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 ab2980ba52ae24db72765b3c4ae1d33ac8fad3f5\n```\n\n3. You will likely have some merge/cherry-pick conflict here, fix them and commit:\n\n```\ngit commit -am 'Backport PR #57689: CI: fix ci (calamine typing)'\n```\n\n4. Push to a named branch:\n\n```\ngit push YOURFORK 2.2.x:auto-backport-of-pr-57689-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 #57689 on branch 2.2.x (CI: fix ci (calamine typing))\"\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,162,749,733
57,688
BUILD: require `python-dateutil>=2.9.0`
closed
2024-03-01T07:06:43
2024-03-16T14:26:50
2024-03-16T14:26:50
https://github.com/pandas-dev/pandas/issues/57688
true
null
null
bersbersbers
3
### Installation check - [X] I have read the [installation guide](https://pandas.pydata.org/pandas-docs/stable/getting_started/install.html#installing-pandas). ### Platform Any ### Installation Method pip install ### pandas Version 2.2.1 ### Python Version 3.12.2 ### Installation Logs Installing `pandas` installs `python-dateutil`. On Python 3.12, `python-dateutil<2.9.0` issues warnings, compare https://github.com/pandas-dev/pandas/issues/57262. I'd suggest enforcing `python-dateutil>=2.9.0` as a dependency, at least on Python 3.12.
[ "Build", "Dependencies", "Closing Candidate" ]
1
0
0
0
0
0
0
0
[ "Related: https://github.com/matplotlib/matplotlib/issues/27841", "2.9.0 was released 19 hours ago. Agreeing with [matplotlib](https://github.com/matplotlib/matplotlib/issues/27841#issuecomment-1973256393), I think that's far too recent to require.", "Yeah we can't do this yet" ]
2,162,222,056
57,687
Breaking change in nightly wheels when assigning to `df.values`, no FutureWarning
closed
2024-02-29T22:42:40
2024-03-16T14:28:08
2024-03-16T14:28:08
https://github.com/pandas-dev/pandas/issues/57687
true
null
null
rossbar
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 df = pd.DataFrame(np.array([[1.]]), index=[1], columns[1]) df.values[np.diag_indices_from(df)] *= 2 ``` ### Issue Description This is something that popped up in the [networkx tests with the pandas nightly wheels](https://github.com/rossbar/networkx/actions/runs/8034082386/job/21945242713) (cf. [SPEC 4](https://scientific-python.org/specs/spec-0004/)), so I figured we'd raise here for awareness. There is an instance of in-place assignment to `df.values` in the NX examples that has begun failing with the pandas nightly wheels: ### On latest stable from pypi (2.2.1) ```python >>> import numpy as np >>> import pandas as pd >>> pd.__version__ '2.2.1' >>> df = pd.DataFrame(np.eye(2), index=[1, 2], columns=[1, 2]) >>> df.values[np.diag_indices_from(df)] *= 2 >>> df 1 2 1 2.0 0.0 2 0.0 2.0 ``` ### On nightly wheels ```python >>> import numpy as np >>> import pandas as pd >>> pd.__version__ '3.0.0.dev0+444.gaabc35abe0' >>> df = pd.DataFrame(np.eye(2), index=[1, 2], columns=[1, 2]) >>> df.values[np.diag_indices_from(df)] *= 2 Traceback (most recent call last) ... ValueError: assignment destination is read-only ``` ### Expected Behavior I assume the actual behavior change is expected as part of pandas-3.0; my goal was to raise awareness that there is no `FutureWarning`/`DeprecationWarning` for the assigning-to-values in the current version of pandas. It may be that this is intentional - if so, please close this issue! FWIW we have caught and fixed [other issues in the NX test suite](https://github.com/networkx/networkx/pull/7209) via deprecation/future warnings. ### Installed Versions Version info included above. Additional context - I tried the same minimal example with a 2.3 dev nightly wheel (`2.3.0.dev0+34.g0c23e18c73`) and no warnings were raised there either.
[ "Bug", "DataFrame", "Copy / view semantics", "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "I wonder if this might be due to CoW - cc @phofl", "Yes it is and the change was intentional ", "> Yes it is and the change was intentional\r\n\r\nThanks @phofl , I figured it was. The core of this issue is whether or not pandas intends to add raise a warning when users try to assign to `.values` - I suspect this pattern exists in user code for others who are not testing against the pandas nightlies. If not please don't hesitate to close, there's no request/action item on our end!", "We can't warn here, we don't have control over what you do with the returned numpy array and we don't want to warn every time a user asks for a numpy array back just in case they might assign to it. It's unfortunate but this will be a breaking change in 3.0 that is very hard to warn about" ]
2,162,218,461
57,686
BUG: Groupby ignores group_keys=False when followed by a rolling calculation
closed
2024-02-29T22:39:11
2025-05-07T14:25:24
2024-03-01T03:08:45
https://github.com/pandas-dev/pandas/issues/57686
true
null
null
furechan
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. - [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 io import pandas as pd DATA = """ ticker,date,price,volume AAA,2021-01-01,10.0,1000 AAA,2021-01-02,11.0,1000 AAA,2021-01-03,12.0,1000 AAA,2021-01-04,11.0,1000 BBB,2021-01-01,20.0,1000 BBB,2021-01-02,21.0,1000 BBB,2021-01-03,22.0,1000 BBB,2021-01-04,21.0,1000 """ f = io.StringIO(DATA) df = pd.read_csv(f, parse_dates=['date'], index_col=[0, 1]) df.price.groupby("ticker", group_keys=False).rolling(2).mean() ``` ### Issue Description A groupby followed by a rolling calculation ignores group_keys=False. In the example below the column ticker appears twice in the result even though we have `group_keys=False` ```python df.price.groupby("ticker", group_keys=False).rolling(2).mean() ``` ### ### Expected Behavior The groupby column 'ticker' should not repeat since we have group_keys=False. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.9.18.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 : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.1 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 58.1.0 pip : 24.0 Cython : None pytest : 8.0.1 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 5.1.0 html5lib : 1.1 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 : None gcsfs : None matplotlib : 3.8.3 numba : 0.59.0 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 : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Groupby" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. The [groupby docs](https://pandas.pydata.org/pandas-docs/dev/reference/api/pandas.DataFrame.groupby.html) state:\r\n\r\n> When calling apply and...\r\n\r\nthe group_keys argument is only to impact `.groupby(...).apply` and not other methods. Closing for now - if you think I've missed something, comment here and we can reopen.", "Indeed, you are right, the docs specifically mention the `group_keys` for the `apply` method.\r\n\r\nTo give some context to my inquiry, when calling say `shift(1)` on the groupby there is no repetition of the index and you get a result with the same index as the original data.\r\n\r\n```\r\ndf.price.groupby(\"ticker\").shift(1)\r\n```\r\n\r\nHowever when calling `rolling(2).mean()` there is repetition of the index. How do we know which method duplicates the index and which does not? And how do we fix the duplicate index ?\r\n\r\nSo here, I was hoping that `group_keys=False` would do the trick.\r\n\r\nAs a side note, I noticed that using `as_index=False` at the dataframe level fixes the issue.\r\n\r\n```\r\ndf.groupby(\"ticker\", as_index=False).price.rolling(2).mean()\r\n```\r\n\r\nHowever `as_index` is applicable only at dataframe level, so it seems that I am left short of a solution when working at the series level...\r\n\r\nThanks for the consideration.\r\n\r\n", "I still think the result in my example is wrong, even if the problem is not with the `group_keys` flag. So if you don't mind, I will create a different issue with a rephrased explanation.\r\nThank you", "Related: #36507", "Groupby did not ignore group_keys=False when followed by a rolling calculation in old versions of pandas (for example, 0.25.1) Why was it broken?" ]
2,162,187,452
57,685
BUG: datetime parsing fails on a leapday
closed
2024-02-29T22:11:43
2024-03-01T22:10:33
2024-02-29T23:25:31
https://github.com/pandas-dev/pandas/pull/57685
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57685
https://github.com/pandas-dev/pandas/pull/57685
rhshadrach
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. No idea what would be a better fix. `dateutil_parse` will substitute parts of the `dt_str` into `default` and then check if it's a valid date.
[ "Bug", "Datetime" ]
0
0
0
0
0
0
0
0
[ "There is another PR also addressing this with a similar approach: #57674", "Thanks - I quickly checked but missed that one. That approach is better." ]
2,162,132,671
57,684
CLN: Enforce deprecation of axis=None in DataFrame reductions
closed
2024-02-29T21:28:18
2024-03-05T23:09:23
2024-03-05T23:04:38
https://github.com/pandas-dev/pandas/pull/57684
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57684
https://github.com/pandas-dev/pandas/pull/57684
rhshadrach
3
- [ ] 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: #52042
[ "Clean", "DataFrame", "Reduction Operations" ]
0
0
0
0
0
0
0
0
[ "Looks good. Just an ASV needs fixing", "Thanks @mroeschke - removed the failing benchmark: with `axis=None` it was now computing `std` over invalid dtypes.", "Thanks @rhshadrach " ]
2,161,869,188
57,683
wip Remove docstring substitutions
closed
2024-02-29T18:37:31
2024-03-31T18:38:34
2024-03-31T18:38:34
https://github.com/pandas-dev/pandas/pull/57683
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57683
https://github.com/pandas-dev/pandas/pull/57683
MarcoGorelli
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.
[]
0
0
0
0
0
0
0
0
[ "So it seems that the advantage of docstring substitutions is that you only document certain things in one place. Otherwise, you have to repeat doc text in multiple places. That could create a future maintenance burden, if you have to change the description of a parameter in multiple places.\r\n\r\nSo maybe the solution would be to write a special code that does the substitutions for the purpose of doing the code validation. Not sure how hard that would be.", "> So it seems that the advantage of docstring substitutions is that you only document certain things in one place.\r\n\r\nThere have been a number of times where I've noticed something wrong with the docs, went to go correct it only to see that I'd have to tease apart and redo a lot of the sharing. Not having the time (and many times, the desire) to do so, I either raised and issue or let it slip.\r\n\r\nWhile I do agree that we may end up with inconsistencies, in my experience I think our docstrings would be a lot better if we made them easier to edit.\r\n\r\nIt is also possible to set up tests to check that e.g. `numeric_only` always has the same description by parsing docstrings. Not certain this is worth the effort, but it's at least possible to do.", "Awesome to see that automation took care of a lot of this! Big +1.\r\n\r\nMaintaining docstrings as purely text is worth the tradeoff of maintaining complex docstring automation and sharing. It will also be more straightforward for new contributors as well.\r\n\r\nIf we want to maintain consistency, we can do that through unit testing instead (we also do this with the docstrings of `Timestamp` and `NaT`", "> There have been a number of times where I've noticed something wrong with the docs, went to go correct it only to see that I'd have to tease apart and redo a lot of the sharing. Not having the time (and many times, the desire) to do so, I either raised and issue or let it slip.\r\n\r\n😄 same\r\n\r\nA bit of copy-and-pasting for docs isn't too bad, and as you've both noted, it's possible to write unit tests to ensure that some docstrings stay in sync\r\n\r\nIf there's no objections, I'll set aside some time to make this happen then (but my first priority is to properly handle pyarrow dtypes in the interchange protocol)", "> A bit of copy-and-pasting for docs isn't too bad, and as you've both noted, it's possible to write unit tests to ensure that some docstrings stay in sync\r\n\r\nIf you can do this, I'm all for it. My concern here is that most contributors won't realize that they have to change some docstring in 4 different files without some kind of unit test checking that.\r\n", "While reusing docstrings can surely make things easier given the amount of duplicated methods in pandas, I do agree that in the current state it's probably creating more trouble than the value it adds. For example, the `make_doc` function to generate docstrings for the reduction functions is surely quite annoying to deal with, see this PR: #57682\r\n\r\nSeems from the comments here that in general we're happy to fully get rid of the duplication, but I don't think a final decision has been made. I see some discussion in different issues and PRs, mostly here, #57578 and #57710, but since the impact is quite big in term of changes to the code, what do you think about creating a specific issue to make a global decision (maybe even a PDEP), on whether we want to do reusing at all, in which well defined cases would it be acceptable if any, and how are we planning to move forward with the changes (maybe some automation like a script to try to identify all the docstrings being reused, and keep an inventory to work on)?\r\n\r\nMaybe I'm too cautious, but feels like we may end up in a situation where we're not well aligned among the core dev team, and we have lots of PRs related to this, also mixed with other possibly conflicting docstring efforts.", "now that the docstring validation has been noticeably sped up in CI, I don't think this is as important - closing then, thanks for comments" ]
2,161,821,635
57,682
DOC: RT03 fix for min,max,mean,meadian,kurt,skew
closed
2024-02-29T18:05:43
2024-04-23T18:53:42
2024-04-23T18:53:42
https://github.com/pandas-dev/pandas/pull/57682
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57682
https://github.com/pandas-dev/pandas/pull/57682
YashpalAhlawat
18
This PR will fix RT03 error for min,max,mean,meadian,kurt,skew methods - [x] xref #57416 - [ ] [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" ]
0
0
0
0
0
0
0
0
[ "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57682/", "Thanks @YashpalAhlawat, great job.\r\n\r\nThere are couple of details that would be good to address. This docstring is also being reused by `Series` methods, you can see how it looks here:\r\n\r\nhttps://pandas.pydata.org/preview/pandas-dev/pandas/57682/docs/reference/api/pandas.Series.kurt.html\r\n\r\nFew things:\r\n- Can we also remove the `Series.kurt`... methods from the validation as we did with the `DataFrame` methods?\r\n- If you see in the description you added, it says `applying the kurt function to the DataFrame elements` when we are in the `Series` docstring. Can you use a parameter so it says `... Series elements` please?\r\n- Finally, this is not from your PR, but if you see the docstring in the link, it says `scalar or scalar` for the return type, which doesn't make sense. I think for DataFrame it should says `Series or scalar` and for Series it should say simply `scalar`. Can you have a look to see if this is really the case, and make the docstring show the correct types please?\r\n\r\nThanks for the help with this!", "> Thanks @YashpalAhlawat, great job.\r\n> \r\n> There are couple of details that would be good to address. This docstring is also being reused by `Series` methods, you can see how it looks here:\r\n> \r\n> https://pandas.pydata.org/preview/pandas-dev/pandas/57682/docs/reference/api/pandas.Series.kurt.html\r\n> \r\n> Few things:\r\n> \r\n> * Can we also remove the `Series.kurt`... methods from the validation as we did with the `DataFrame` methods?\r\n> * If you see in the description you added, it says `applying the kurt function to the DataFrame elements` when we are in the `Series` docstring. Can you use a parameter so it says `... Series elements` please?\r\n> * Finally, this is not from your PR, but if you see the docstring in the link, it says `scalar or scalar` for the return type, which doesn't make sense. I think for DataFrame it should says `Series or scalar` and for Series it should say simply `scalar`. Can you have a look to see if this is really the case, and make the docstring show the correct types please?\r\n> \r\n> Thanks for the help with this!\r\n\r\n@datapythonista , All points has been addressed. If you have any other approach in mind to address third point. I will be happy to make changes in my implementation for that.\r\n\r\nThanks\r\n", "Thanks for the updates @YashpalAhlawat. It would be good to change the parameters of `name1`, `name2` as needed in a static way. The idea is that we have a template we use in different methods. And when reusing the template we specify the values for each function. So, you can have a value `Series or scalar` or `scalar` as appropriate so the type renders correctly without requiring extra complexity. Does this make sense?", "> Thanks for the updates @YashpalAhlawat. It would be good to change the parameters of `name1`, `name2` as needed in a static way. The idea is that we have a template we use in different methods. And when reusing the template we specify the values for each function. So, you can have a value `Series or scalar` or `scalar` as appropriate so the type renders correctly without requiring extra complexity. Does this make sense?\r\n\r\n@datapythonista , I have implemented a solution in a similar manner. It is functioning as expected. I would appreciate your feedback. If you believe there is a better approach, I am open to making the necessary changes.", "/preview\r\n", "Thanks a lot for working on this @YashpalAhlawat.\r\n\r\nI've been checking, and it's quite complex how we are generating these docstrings. I think I'm happy to merge your changes as they are if you want, but while it fixes the problems with the docstrings you are fixing here, it adds even a bit more complexity to the function. Also, there will still be docstrings with related problems, for example https://pandas.pydata.org/docs/reference/api/pandas.Series.sum.html will still have the `scalar or scalar` return.\r\n\r\nWhat do you think about replacing `name1` and `name2` and using `return_type` instead containing both values together for all cases (e.g. `DataFrame or Series`, `Series or scalar`, `scalar`)? In some cases, that would require changing the description of the return, to avoid having the type (same as you did in one of the iterations of this PR, focusing on what is being returned conceptually instead of in the types).\r\n\r\nFinally, I think it'd be good to move the code of condition `if ndim == 1:` at the end of the `make_doc` function, so you can have the `if` you added together with the settings of the other `return_type` (`name1` and `name2` now).\r\n\r\nSo, you'll have something like:\r\n\r\n```python\r\n if ndim == 1:\r\n return_type = \"Series or scalar\"\r\n axis_descr = \"{index (0)}\"\r\n else:\r\n if base_doc in (_num_doc, _sum_prod_doc):\r\n return_type = \"scalar\"\r\n else:\r\n return_type = \"Series or scalar\"\r\n axis_descr = \"{index (0), columns (1)}\"\r\n```\r\n\r\nNot sure if what we should do is to remove this function and simplify how docstrings are being reused, but I think this way at least things don't get too much more complicated than now. What do you think?", "@datapythonista ,\r\n\r\nI would love to change the code for all. \r\nBut #57683 focuses on removing such code and adding string directly to methods.\r\n\r\nShouldn't I remove all logic and put doc strings directly to methods.\r\n", "> Shouldn't I remove all logic and put doc strings directly to methods.\r\n\r\nYes, if you want to do that, I think for this case everybody will surely agree, the complexity here is quite high as you already experienced. If you do it, it's better to do it step by step, we can probably have a PR for every base docstring. Or as you think it makes sense, but not replacing the whole `make_doc` function in a single PR, that'll be very hard to review.\r\n\r\nThanks a lot for the work on this @YashpalAhlawat ", "@datapythonista ,\r\n\r\nI have updated the code as per suggestion.\r\n\r\nFor removing all the code and putting plain docstrings in methods. That can be picked separately once this PR is merged.", "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57682/", "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57682/", "@YashpalAhlawat you'll have to resolve the conflicts, we changed how the ignored errors are specified in `code_checks.sh`.", "@datapythonista , Could you please review this. So that I can close this and move on to some other task.\r\n\r\nThanks!!", "Thanks for the PR but it appears this PR has gone stale and needs a rebase. Closing but feel free to ping once you have addressed the conflicts and want to keep working on this" ]
2,161,619,894
57,681
BUG: pandas can't detect matplotlib on nanoserver (works fine on servercore)
closed
2024-02-29T16:15:02
2024-03-18T01:12:59
2024-03-18T01:12:58
https://github.com/pandas-dev/pandas/issues/57681
true
null
null
robin-deltares
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. - [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 #FROM mcr.microsoft.com/windows/servercore:ltsc2022 FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 ADD python C:/python RUN setx path "C:\python;C:\python\scripts;%PATH%" RUN python -m pip install matplotlib pandas << Then use pandas inside container >> ``` ### Issue Description Build a Docker container using mcr.microsoft.com/windows/nanoserver:ltsc2022 with python (identical behavior with 3.7 and 3.12) and any versions of pandas+matplotlib. Use pandas library. File "C:\python\Lib\site-packages\pandas\plotting\_core.py", line 1874, in _load_backend raise ImportError( ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected. Works fine when running identical code on mcr.microsoft.com/windows/servercore:ltsc2022 Docker container. ### Expected Behavior Should work with nanoserver too. ### Installed Versions Tried with many versions of pandas and matplotlib.
[ "Bug", "Needs Info" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. Why do you think this is an issue with pandas?", "closing, please ping to reopen if you can provide more context" ]
2,161,516,678
57,680
BUG: Subtraction fails with matching index of different name and type (pandas-dev#57524)
closed
2024-02-29T15:24:23
2024-03-20T17:30:54
2024-03-20T17:30:53
https://github.com/pandas-dev/pandas/pull/57680
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57680
https://github.com/pandas-dev/pandas/pull/57680
Adasjo
1
- [x] closes #57524 - [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/v3.0.0.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[ "Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen." ]
2,161,441,550
57,679
BUG: pd.unique(Index) now returns Index as Index.unique
closed
2024-02-29T14:49:53
2024-03-13T03:58:37
2024-03-12T17:26:38
https://github.com/pandas-dev/pandas/pull/57679
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57679
https://github.com/pandas-dev/pandas/pull/57679
yuanx749
3
Some old tests are adjusted for consistency. - [x] closes #57043(Replace xxxx with the GitHub issue number) - [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.
[ "Algos", "Index" ]
0
0
0
0
0
0
0
0
[ "Looks like CI failures are not related. Could you please review this PR? @rhshadrach ", "Thank you for the review. I push a new commit to address the requests. @rhshadrach ", "Thanks @yuanx749 " ]
2,161,111,885
57,678
DOC: Extended the documentation for `DataFrame.sort_values()`
closed
2024-02-29T12:11:25
2024-03-05T20:50:40
2024-03-05T20:50:32
https://github.com/pandas-dev/pandas/pull/57678
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57678
https://github.com/pandas-dev/pandas/pull/57678
aallahyar
6
The current docstring for [`DataFrame.sort_values()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sort_values.html) is lacking clarity, and also contains links that are not converted to hyperlinks. I extended and rephrased part of the documentation for this method. In particular: - Added further explanation to compare the single-column vs. multi-column sorting, - Extended explanation for customized sorting via `key` argument, - Provided a simplified version of `natsort` example, with added explanation.
[ "Docs", "Sorting" ]
0
0
0
0
0
0
0
0
[ "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57678/", "The rendered version of the changes here is available [here](https://pandas.pydata.org/preview/pandas-dev/pandas/57678/docs/reference/api/pandas.DataFrame.sort_values.html), in case it's useful.", "Thanks @datapythonista for reviewing the update!\r\n\r\nWould be happy to fix the issue. Please take a look.\r\n\r\nAlso thank you for the guidance!\r\nIt is indeed my first contribution to a large project, so I have a lot to learn 😄 ", "@datapythonista could you please let me know if any other modification is needed for this PR?\r\n\r\nThanks :)", "Thanks @aallahyar " ]
2,160,939,752
57,677
DOC: Extended the documentation for `DataFrame.sort_values()`
closed
2024-02-29T10:36:50
2024-02-29T10:59:54
2024-02-29T10:59:54
https://github.com/pandas-dev/pandas/pull/57677
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57677
https://github.com/pandas-dev/pandas/pull/57677
aallahyar
0
The current docstring for [`DataFrame.sort_values()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sort_values.html) is lacking clarity, and also contains links that are not converted to hyperlinks. I extended and rephrased part of the documentation for this method. In particular: - Added further explanation to compare the single-column vs. multi-column sorting, - Extended explanation for customized sorting via `key` argument, - Provided a simplified version of `natsort` example, with added explanation.
[]
0
0
0
0
0
0
0
0
[]
2,160,876,068
57,676
BUG: `join` with `list` does not behave like singleton
open
2024-02-29T10:03:33
2024-03-25T08:45:15
null
https://github.com/pandas-dev/pandas/issues/57676
true
null
null
ilan-gold
6
### 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 cat_df = pd.DataFrame({'cat': pd.Categorical(['a', 'v', 'd'])}, index=pd.Index(['a', 'b', 'c'], name='y')) join_df = pd.DataFrame({'foo': np.arange(6)}, index = pd.MultiIndex.from_tuples([(0, 'a'), (0, 'b'), (0, 'c'), (1, 'a'), (1, 'b'), (1, 'c')], names=('x', 'y')) ) join_df.join([cat_df]) # NaNs in the `cat` column join_df.join(cat_df) # correct ``` ### Issue Description I would expect the result to be identical. I am really interested in being able to left join multiple `cat_df`s that share (one of) an index with the `join_df`. ### Expected Behavior I would expect identical behavior. I did notice that with the `on` `kwarg`, I get an error that might indicate this is not allowed: ```python join_df.join([cat_df], on='y') ``` gives ```python Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/ilangold/Projects/Theis/pandas/pandas/core/frame.py", line 10463, in join raise ValueError( ValueError: Joining multiple DataFrames only supported for joining on index ``` ### Installed Versions Not sure what's up with the installed version commit since my `git log` looks like ``` commit e14a9bd41d8cd8ac52c5c958b735623fe0eae064 (HEAD -> main, origin/main, origin/HEAD) Author: Eric Larson <[email protected]> Date: Wed Feb 28 17:21:32 2024 -0500 ENH: Report how far off the formatting is (#57667) ``` <details> INSTALLED VERSIONS ------------------ commit : 52cb549f443f09727448251cfee53227c6bca9d2 python : 3.11.6.final.0 python-bits : 64 OS : Darwin OS-release : 22.6.0 Version : Darwin Kernel Version 22.6.0: Wed Oct 4 21:26:23 PDT 2023; root:xnu-8796.141.3.701.17~4/RELEASE_ARM64_T6000 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : None LOCALE : None.UTF-8 pandas : 3.0.0.dev0+87.g52cb549f44.dirty numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 68.2.2 pip : 23.3.1 Cython : 3.0.8 pytest : 8.0.2 hypothesis : 6.98.13 sphinx : 7.2.6 blosc : None feather : None xlsxwriter : 3.2.0 lxml.etree : 5.1.0 html5lib : 1.1 pymysql : 1.4.6 psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : 8.22.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.8 fastparquet : 2024.2.0 fsspec : 2024.2.0 gcsfs : 2024.2.0 matplotlib : 3.8.3 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pyarrow : 15.0.0 pyreadstat : 1.2.6 python-calamine : None pyxlsb : 1.0.10 s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : 2.0.27 tables : 3.9.2 tabulate : 0.9.0 xarray : 2024.2.0 xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "take", "I believe the problem is that whenever join receives a list, that list is evaluated and then it either is concatenated or merged. With the current evaluation method [cat_df] is getting concatenated with join_df while cat_df gets merged with join_df. In my pull request I naively changed this evaluation to fix this issue but now it fails several other join tests. I'll look into the theory about concatenation vs merging in further detail and update the pull request.", "Figured out that the simpler way to deal with this is that whenever a list of a single element is passed, convert it into a join with another element. The operation that evaluates the boolean \"can_concat\" has been there for 12 years (doubt it's wrong), however there might have been an oversight for some specific cases of this uncommon practice (passing a list with a single element).", "@Dacops I will say that it isn't my _intention_ to pass a single item list, but when you are creating the lists from other things, it can happen.", "Yeah that makes sense, meanwhile I've sent the pull request and it passed everything in the pipeline so now it's just waiting for a developer review", "Thanks so much @Dacops :)" ]
2,160,853,174
57,675
WEB: Remove unmaintained projects from Ecosystem
closed
2024-02-29T09:51:32
2024-03-05T00:53:59
2024-03-05T00:53:52
https://github.com/pandas-dev/pandas/pull/57675
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57675
https://github.com/pandas-dev/pandas/pull/57675
datapythonista
1
Lots of projects in our Ecosystem page seem to be obsolete and irrelevant now. There are few more that could probably be removed to help users find the relevant ones faster and easier, but I'm just removing the ones that didn't have any commit for at least two years.
[ "Web" ]
0
0
0
0
0
0
0
0
[ "Thanks @datapythonista " ]
2,160,783,341
57,674
CI: avoid `guess_datetime_format` failure on 29th of Feburary
closed
2024-02-29T09:19:22
2024-03-05T20:15:00
2024-03-05T20:14:53
https://github.com/pandas-dev/pandas/pull/57674
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57674
https://github.com/pandas-dev/pandas/pull/57674
MarcoGorelli
5
- [ ] closes #57672 (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", "CI" ]
0
0
0
0
0
0
0
0
[ "Looks reasonable. I guess it would be a PITA to write a test?", "> Looks reasonable. I guess it would be a PITA to write a test?\r\n\r\ngiven that the function calls `datetime.now` from Cython - yes, probably", "Looks good. Could you double check this typing issue? https://github.com/pandas-dev/pandas/actions/runs/8108693644/job/22162385490?pr=57674", "thanks - that one should be addressed in https://github.com/pandas-dev/pandas/pull/57689", "Thanks @MarcoGorelli " ]
2,160,730,544
57,673
BUG: fastparquet interface fails on load with non-unique index and CoW
closed
2024-02-29T08:50:24
2024-03-07T19:33:57
2024-03-06T20:06:04
https://github.com/pandas-dev/pandas/issues/57673
true
null
null
max3-2
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 from pathlib import Path import pandas as pd import numpy as np # Set the random seed for reproducibility np.random.seed(42) # Create random data data = { 'Integer_Column': np.random.randint(0, 100, size=30), 'Float_Column': np.random.uniform(0, 1, size=30), 'String_Column1': [np.random.choice(['apple', 'banana', 'orange']) for _ in range(30)], 'String_Column2': [np.random.choice(['cat', 'dog', 'rabbit']) for _ in range(30)], 'String_Column3': [np.random.choice(['red', 'blue', 'green']) for _ in range(30)] } target = Path('sample_file_test.parquet') # Create DataFrame df = pd.DataFrame(data) # Make index non-unique! df.index = np.random.randint(0, 5, size=30) df = df.sort_index() # Write the parquet df.to_parquet(target, engine='fastparquet') # Load with CoW, error pd.options.mode.copy_on_write = True df_loaded = pd.read_parquet(target) # Load with warn - no warning AND data loads pd.options.mode.copy_on_write = 'warn' df_loaded = pd.read_parquet(target) ``` ### Issue Description When writing a dataframe using the `fastparquet` engine of pandas that contains **non-unique indexing**, reloading said dataframe fails. While the error is, in core, thrown by `fastparquet` I report it here since its directly related to the upcoming changes in `pandas` ### Expected Behavior See example above - it is expected that the data loads back in as it is with the old settings of `CoW` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.11.4.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19045 machine : AMD64 processor : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel byteorder : little LC_ALL : None LANG : en LOCALE : de_DE.cp1252 pandas : 2.2.0 numpy : 1.24.4 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 68.2.2 pip : 23.2.1 Cython : 3.0.0 pytest : None hypothesis : None sphinx : 7.2.6 blosc : None feather : None xlsxwriter : 3.1.9 lxml.etree : 4.9.3 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.17.2 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : None dataframe-api-compat : None fastparquet : 2024.2.0 fsspec : 2023.10.0 gcsfs : None matplotlib : 3.8.1 numba : 0.57.1 numexpr : 2.8.7 odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.11.1 sqlalchemy : None tables : 3.8.0 tabulate : None xarray : None xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2023.3 qtpy : 2.4.1 pyqt5 : None </details>
[ "Bug", "IO Parquet", "Upstream issue" ]
0
0
0
0
0
0
0
0
[ "@max3-2 Thanks for the report. It's hard to say without seeing a traceback of the error you get, but I assume this is an issue in fastparquet: https://github.com/dask/fastparquet/issues/919 (essentially, fastparquet is not yet fully compatible with the new CoW mode)", "The error is indeed \"ValueError: assignment destination is read-only\", so I am going to close this in favor of the issue on the fastparquet side (as this is something that needs to fixed there): https://github.com/dask/fastparquet/issues/919", "Yeah my bad I skipped the traceback in favor of the repoducer. But yes, the error reported is the one I was referring to and since it only occurs with non-unique indexing I placed it here.\r\nThanks for referring to the other issue!" ]