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,160,456,617
57,672
BUG: List of years (as string) raises UserWarning with to_datetime
closed
2024-02-29T06:04:01
2024-03-05T20:14:54
2024-03-05T20:14:54
https://github.com/pandas-dev/pandas/issues/57672
true
null
null
jrmylow
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [ ] 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 >>> pandas.to_datetime(["2019"]) DatetimeIndex(['2019-01-01'], dtype='datetime64[ns]', freq=None) >>> pandas.to_datetime(["2030-01-01", "2020-01-01"]) DatetimeIndex(['2030-01-01', '2020-01-01'], dtype='datetime64[ns]', freq=None) >>> pandas.to_datetime(["2019", "2020"]) <stdin>:1: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format. DatetimeIndex(['2019-01-01', '2020-01-01'], dtype='datetime64[ns]', freq=None) ``` ### Issue Description List of years (as strings) provided to `to_datetime` raises UserWarning. For some reason, single years and lists of dates do not trigger this warning. This is breaking tests in CI. ### Expected Behavior Expect no userwarning. ### Installed Versions N/A
[ "Bug", "datetime.date" ]
0
0
0
0
0
0
0
0
[ "Update: The calling chain is:\r\n\r\n* `to_datetime` is called from `tests/series/methods/test_nlargest.py`\r\n* Within `core/tools/datetimes.py` it calls:\r\n * `to_datetime`\r\n * `convert_listlike`\r\n * `_convert_listlike_datetimes`\r\n * `_guess_datetime_format_for_array`\r\n * `guess_datetime_format` which returns None\r\n* Over in `_libs/tslibs/parsing.pyx`:\r\n * `guess_datetime_format`\r\n * `dateutil_parse` which raises `ValueError`\r\n * `default.replace(**repl)` raises `DateParseError`\r\n\r\nWhen testing with python:\r\n```python\r\nimport datetime as dt\r\na = dt.datetime.today()\r\na.replace(**{'year': 2003})\r\n\r\n# alternatively\r\na.replace(year=2003)\r\n```\r\nBoth will raise `ValueError: day is out of range for month`.\r\n\r\nI suspect this may be a weird change in cpython? Let me check there", "Update: \"year is out of day for month\" is raised because today is Feb 29th.", "> For some reason, single years and lists of dates do not trigger this warning.\r\n\r\nif there's only a single element, then there's nothing to be inconsistent with\r\n\r\nI think this is expected\r\n\r\n> Update: \"year is out of day for month\" is raised because today is Feb 29th.\r\n\r\nyup, this is the issue, thanks for the triage :)" ]
2,160,328,911
57,671
CLN: Enforce deprecation of pinning name in SeriesGroupBy.agg
closed
2024-02-29T04:24:12
2024-03-05T00:46:31
2024-03-05T00:40:27
https://github.com/pandas-dev/pandas/pull/57671
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57671
https://github.com/pandas-dev/pandas/pull/57671
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: #51703
[ "Groupby", "Clean", "Apply" ]
0
0
0
0
0
0
0
0
[ "@datapythonista - if you tag enforcements of deprecations as \"Deprecate\", our CI will add it to the list of deprecations to enforce in pandas 4.0. I think most are sticking to \"Clean\" for the enforcement.", "Ah, thanks for the heads up, I forgot the bot.", "Thanks @rhshadrach " ]
2,160,265,182
57,670
DOC: Update drop duplicates documentation to specify method limitation
closed
2024-02-29T03:11:19
2024-03-05T01:45:57
2024-03-05T00:55:24
https://github.com/pandas-dev/pandas/pull/57670
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57670
https://github.com/pandas-dev/pandas/pull/57670
flaviaouyang
1
- [x] closes #56784
[ "Docs", "duplicated" ]
0
0
0
0
0
0
0
0
[ "Thanks @flaviaouyang " ]
2,160,221,864
57,669
Potential regression induced by commit 6ef44f2
closed
2024-02-29T02:20:29
2024-02-29T02:52:48
2024-02-29T02:52:48
https://github.com/pandas-dev/pandas/issues/57669
true
null
null
rhshadrach
1
PR #57575 may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. - [ ] [algos.isin.IsInFloat64.time_isin](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInFloat64.time_isin) - [ ] [dtype='Float64'; title='few_different_values'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInFloat64.time_isin?p-dtype=%27Float64%27&p-title=%27few_different_values%27) - [ ] [dtype='Float64'; title='only_nans_values'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInFloat64.time_isin?p-dtype=%27Float64%27&p-title=%27only_nans_values%27) - [ ] [dtype=<class 'numpy.float64'>; title='few_different_values'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInFloat64.time_isin?p-dtype=%3Cclass%20%27numpy.float64%27%3E&p-title=%27few_different_values%27) - [ ] [dtype=<class 'numpy.float64'>; title='only_nans_values'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInFloat64.time_isin?p-dtype=%3Cclass%20%27numpy.float64%27%3E&p-title=%27only_nans_values%27) - [ ] [series_methods.Fillna.time_bfill](https://asv-runner.github.io/asv-collection/pandas/#series_methods.Fillna.time_bfill) - [ ] [dtype='Int64'](https://asv-runner.github.io/asv-collection/pandas/#series_methods.Fillna.time_bfill?p-dtype=%27Int64%27) - [ ] [dtype='datetime64[ns]'](https://asv-runner.github.io/asv-collection/pandas/#series_methods.Fillna.time_bfill?p-dtype=%27datetime64%5Bns%5D%27) Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. [Commit Range](https://github.com/pandas-dev/pandas/compare/7bb427e6ffd31b0951d56e5d0f839726aa64ccee...6ef44f26e3a1f30769c5c0499b2420918a036401) cc @WillAyd
[ "Performance", "Regression", "Internals" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach . I think @DeaMariaLeon also found this via conbench - should be fixed from https://github.com/pandas-dev/pandas/pull/57618" ]
2,160,053,175
57,668
CLN: More numpy 2 stuff
closed
2024-02-28T23:30:02
2024-03-02T19:52:13
2024-03-02T19:52:12
https://github.com/pandas-dev/pandas/pull/57668
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57668
https://github.com/pandas-dev/pandas/pull/57668
lithomas1
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.
[ "Compat", "Clean" ]
0
0
0
0
0
0
0
0
[ "I merged main thinking the CI failures would be gone by now but looks like they are still around. Happy to merge as is given I am fairly confident the failures are unrelated, but will leave it up to you", "Merging then, since numpy is blocked on this.\r\n\r\nThanks for the review!" ]
2,159,822,615
57,667
ENH: Report how far off the formatting is
closed
2024-02-28T20:34:52
2024-02-28T22:56:28
2024-02-28T22:21:32
https://github.com/pandas-dev/pandas/pull/57667
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57667
https://github.com/pandas-dev/pandas/pull/57667
larsoner
1
- [ ] closes #xxxx (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 - [ ] 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 this warrants a ~~test change or~~ `whatsnew` entry but I can add it if requested -- just takes the error message and makes it more informative: ``` E UserWarning: Cell contents too long (54416), truncated to 32767 characters ```
[ "Enhancement", "IO Excel", "Warnings" ]
0
0
0
0
0
0
0
0
[ "Thanks @larsoner!" ]
2,159,798,305
57,666
BUG: pyarrow stripping leading zeros with dtype=str
open
2024-02-28T20:18:06
2025-08-06T14:27:15
null
https://github.com/pandas-dev/pandas/issues/57666
true
null
null
dadrake3
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 from io import StringIO x = """ AB|000388907|abc|0150 AB|101044572|abc|0150 AB|000023607|abc|0205 AB|100102040|abc|0205 """ df_arrow = pd.read_csv( StringIO(x), delimiter="|", header=None, dtype=str, engine="pyarrow", keep_default_na=False, ) df_python = pd.read_csv( StringIO(x), delimiter="|", header=None, dtype=str, engine="python", keep_default_na=False, ) df_arrow 0 1 2 3 0 AB 388907 abc 150 1 AB 101044572 abc 150 2 AB 23607 abc 205 3 AB 100102040 abc 205 df_python 0 1 2 3 0 AB 000388907 abc 0150 1 AB 101044572 abc 0150 2 AB 000023607 abc 0205 3 AB 100102040 abc 0205 ``` ### Issue Description when I use engine=pyarrow and set dtype to str i am seeing the leading zeros in my numeric columns removed even though the resulting column type is 'O'. When I use the python engine I see that the leading zeros are still there as expected. ### Expected Behavior I would expect when treating all columns as strings that the leading zeros are retained and the data is unmodified. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.8.final.0 python-bits : 64 OS : Linux OS-release : 6.5.0-17-generic Version : #17-Ubuntu SMP PREEMPT_DYNAMIC Thu Jan 11 14:20:13 UTC 2024 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : None 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 : 24.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : 2.0.27 tables : None tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "IO CSV", "Arrow" ]
0
0
0
0
0
0
0
2
[ "can confirm this in 2.2.1", "Do you get the same result when you use the `pyarrow.csv.read_csv` method directly? https://arrow.apache.org/docs/python/generated/pyarrow.csv.read_csv.html", "seems to be a problem with the pyarrow engine in pandas (pandas 2.2.1, pyarrow 15.0.1)\r\n```\r\npandas engine pandas dtype: 01\r\npyarrow engine pandas dtype: 1\r\npandas engine pyarrow dtype: 01\r\npyarrow engine pyarrow dtype: 1\r\npyarrow native: 01\r\n```\r\n\r\n```python\r\nimport io\r\n\r\nimport pandas as pd\r\nimport pyarrow as pa\r\nfrom pyarrow import csv\r\n\r\ncsv_file = io.BytesIO(\r\n \"\"\"a\r\n01\"\"\".encode()\r\n)\r\n\r\n\r\nprint(f\"pandas engine pandas dtype: {pd.read_csv(csv_file, dtype=str).iloc[0,0]}\")\r\n\r\ncsv_file.seek(0)\r\nprint(\r\n f\"pyarrow engine pandas dtype: {pd.read_csv(csv_file, dtype=str, engine='pyarrow').iloc[0,0]}\"\r\n)\r\n\r\ncsv_file.seek(0)\r\nprint(\r\n f\"pandas engine pyarrow dtype: {pd.read_csv(csv_file, dtype='str[pyarrow]').iloc[0,0]}\"\r\n)\r\n\r\ncsv_file.seek(0)\r\nprint(\r\n f\"pyarrow engine pyarrow dtype: {pd.read_csv(csv_file, dtype='str[pyarrow]', engine='pyarrow').iloc[0,0]}\"\r\n)\r\n\r\ncsv_file.seek(0)\r\nconvert_options = csv.ConvertOptions(column_types={\"a\": pa.string()})\r\nprint(\r\n f\"pyarrow native: {csv.read_csv(csv_file, convert_options=convert_options).column(0).to_pylist()[0]}\"\r\n)\r\n\r\n```", "take", "For context, the reason this is happening is because currrently the `dtype` argument is only handled as post-processing after pyarrow has read the CSV file. So, currently, we let pyarrow read the csv file with inferring (in this case) numerical types, and then afterwards we cast the result to the specified dtype (in this case `str`). So that explains why the leading zeros are lost.\r\n\r\nhttps://github.com/pandas-dev/pandas/blob/e51039afe3cbdedbf5ffd5cefb5dea98c2050b88/pandas/io/parsers/arrow_parser_wrapper.py#L216\r\n\r\nPyArrow does provide a `column_types` keyword to specify the dtype while reading: https://arrow.apache.org/docs/python/generated/pyarrow.csv.ConvertOptions.html#pyarrow.csv.ConvertOptions\r\n\r\nSo what we need to do is translate the `dtype` keyword in `read_csv` to the `column_types` argument for pyarrow, somewhere here:\r\n\r\nhttps://github.com/pandas-dev/pandas/blob/e51039afe3cbdedbf5ffd5cefb5dea98c2050b88/pandas/io/parsers/arrow_parser_wrapper.py#L120-L134\r\n\r\nAs a first step, I would just try to enable specifying it for a specific column, like `dtype={\"a\": str}`, because for something like `dtype=str` which applies to all columns, with the current pyarrow API you would need to know the column names up front (pyarrow only accepts specifying it per column, not for all columns at once)", "Still encountering this issue with pyarrow version: 20.0.0 and pandas version: 2.3.0", "From my review of `arrow_parser_wrapper.py` (see @jorisvandenbossche's comment above), I think there are a few steps:\n\n1. In `_get_pyarrow_options`, `self.dtype` needs to be mapped to `self.kwds[\"column_types\"]`. In order to do this effectively, we need:\n- pandas to pyarrow type conversion (does this fn exist?) so that we can supply native dtype function types. Alternatively, we could just pass them to pyarrow \"as is\" and let pyarrow raise exceptions as needed. \n- an ordered list of all columns (does this fn exist?) in the case that no specific column names are provided or in the case that (I believe) columns are specified by index\n- `self.convert_options` needs to be amended to include `column_types` as an allowable kwd\n\n2. In `_finalize_pandas_output`, `self.dtype` handling should be amended to handle the index_col logic. We may need the ordered column list for this.\n\n3. In `_finalize_pandas_output`, remaining `self.dtype` post processing should be removed. This is causing bugs in the logic (e.g., stripping leading zeros).\n\n\nI tested some of these steps locally, and it works.", "The issue arises because the relevant section of the pandas source code (as referenced by @jorisvandenbossche) does not properly handle pyarrow's column_types. To address this, we simply need to add a line immediately after defining self.convert_options (around line 130):\n\n`self.convert_options[\"column_types\"] = self.kwds.get(\"dtype\", {})\n`\nP.S.: This was observed using pandas 2.3.1 and pyarrow 21.0.0.", "@marianobiondo thx for your reply, but there are some caveats as I was pointing out:\n\n- pandas is a lot more friendly in how dtypes can be specified. we need to map those to native pyarrow implementations\n> for ex, pandas can have dtype: str which applies to all columns or even dtype matching by col index (not name).\n\nNot sure Pyarrow can handle these specified as native python types for example. Pyarrow has more limitations. That's why I laid out the steps above. \n\nThat being said, mapping it internally to Pyarrow would also be an option (and cross-posting the issue on their library). Then we could go with your suggestion." ]
2,159,746,508
57,665
BUG: interchange protocol with nullable datatypes a non-null validity
closed
2024-02-28T19:56:04
2024-04-10T12:07:45
2024-03-07T19:55:05
https://github.com/pandas-dev/pandas/pull/57665
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57665
https://github.com/pandas-dev/pandas/pull/57665
MarcoGorelli
2
- [ ] closes #57643 (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. This deals with pandas nullable dtypes pyarrow nullables ones will require changes to the PandasBuffer class, so I'll handle those separately
[ "Interchange" ]
0
0
0
0
0
0
0
0
[ "Thanks @MarcoGorelli ", "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 03717bcc5ae762d8a0ab8d259ca000af66e8ba82\n```\n\n3. You will likely have some merge/cherry-pick conflict here, fix them and commit:\n\n```\ngit commit -am 'Backport PR #57665: BUG: interchange protocol with nullable datatypes a non-null validity'\n```\n\n4. Push to a named branch:\n\n```\ngit push YOURFORK 2.2.x:auto-backport-of-pr-57665-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 #57665 on branch 2.2.x (BUG: interchange protocol with nullable datatypes a non-null validity)\"\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,159,730,996
57,664
BUG: interchange protocol with nullable pyarrow datatypes a non-null validity provides nonsense results
closed
2024-02-28T19:49:13
2024-03-20T21:10:57
2024-03-20T21:10:57
https://github.com/pandas-dev/pandas/issues/57664
true
null
null
MarcoGorelli
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pyarrow.interchange as pai import pandas as pd import polars as pl data = pd.DataFrame( { "b1": pd.Series([1, 2, None], dtype='Int64[pyarrow]'), } ) print(pd.api.interchange.from_dataframe(data.__dataframe__())) print(pai.from_dataframe(data)) print(pl.from_dataframe(data)) ``` ### Issue Description Result: ``` b1 0 4607182418800017408 1 4611686018427387904 2 9221120237041090560 pyarrow.Table b1: int64 ---- b1: [[4607182418800017408,4611686018427387904,9221120237041090560]] shape: (3, 1) ┌─────────────────────┐ │ b1 │ │ --- │ │ i64 │ ╞═════════════════════╡ │ 4607182418800017408 │ │ 4611686018427387904 │ │ 9221120237041090560 │ └─────────────────────┘ ``` ### Expected Behavior `[1, 2, None]` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : 92a52e231534de236c4e878008a4365b4b1da291 python : 3.10.12.final.0 python-bits : 64 OS : Linux OS-release : 5.15.133.1-microsoft-standard-WSL2 Version : #1 SMP Thu Oct 5 21:02:42 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 3.0.0.dev0+355.g92a52e2315 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 59.6.0 pip : 24.0 Cython : 3.0.8 pytest : 8.0.0 hypothesis : 6.98.6 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.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.7 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.1.1 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
[ "same as https://github.com/pandas-dev/pandas/issues/57643, but for pyarrow nullable", "Oof...I think this is a lifecycle issue similar to https://github.com/data-apis/dataframe-api/issues/351\r\n\r\nLooking at the pandas implementation, we are doing:\r\n\r\n```python\r\n elif self.dtype[0] in (\r\n DtypeKind.INT,\r\n DtypeKind.UINT,\r\n DtypeKind.FLOAT,\r\n DtypeKind.BOOL,\r\n ):\r\n np_arr = self._col.to_numpy()\r\n buffer = PandasBuffer(np_arr, allow_copy=self._allow_copy)\r\n dtype = self.dtype\r\n```\r\n\r\nFor non-null arrow arrays this \"works\" by pure coincidence. The `self._col.to_numpy()` call is zero-copy from Arrow -> NumPy, and creates a view that does not own the data. When that NumPy array goes out of scope the memory address it stored is still valid as long as the original PyArrow array is:\r\n\r\nBy contrast, when there are null values present it is no longer a zero-copy exchange, so when `buffer` and `np_arr` get garbage collected the heap storage `np_arr` pointed to originally is free'd. Someone somewhere else still has a buffer that points to this location, but it is garbage.\r\n\r\nI think this is a rather large deficiency in the protocol", "As you have already mentioned `self._col.to_numpy()` is also not really viable if it performs any kind of conversions, which in this case it does. There are any number of workarounds to that problem although I think we are best served in the long term if we stop trying to fit everything through a numpy lens and create the buffer managing objects we need at a lower level" ]
2,159,600,776
57,663
BUG: melt no longer supports id_vars and value_vars collapsing levels accross MultiIndex
open
2024-02-28T18:36:31
2025-06-02T17:16:17
null
https://github.com/pandas-dev/pandas/issues/57663
true
null
null
mark-thm
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 pandas as pd period1 = pd.Period("2018Q1") df = pd.DataFrame( [[1.0]], index=pd.PeriodIndex([period1, period1], name="period"), columns=pd.MultiIndex.from_tuples( [("a", "b")], names=["x", "y"], ), ) pd.melt(df, id_vars=["a"]) ``` ### Issue Description Starting in 2.2.0, pd.melt claims that columns referenced in id_vars or value_vars are not present in a MultiIndex: ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "venv/lib/python3.11/site-packages/pandas/core/reshape/melt.py", line 74, in melt raise KeyError( KeyError: "The following id_vars or value_vars are not present in the DataFrame: ['a']" ``` ### Expected Behavior Prior to 2.2.0, pd.melt melts the dataframe. It appears the behavior was changed in this commit: https://github.com/pandas-dev/pandas/pull/55948/files#diff-a851c9e0a30604de55d051b077b0d9d2ab92d2386863991a2a4cb4444f103bffL44-L50 ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : fd3f57170aa1af588ba877e8e28c158a20a4886d python : 3.11.7.final.0 python-bits : 64 OS : Darwin OS-release : 23.3.0 Version : Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.1.0 pip : 23.2.1 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 : 1.4.6 psycopg2 : None jinja2 : 3.1.3 IPython : 8.9.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.7 dataframe-api-compat : None fastparquet : None 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 pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : 1.0.10 s3fs : 2024.2.0 scipy : 1.12.0 sqlalchemy : None tables : None tabulate : None xarray : 2024.2.0 xlrd : None zstandard : None tzdata : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Reshaping", "Regression" ]
4
0
0
0
0
0
0
0
[ "cc @mroeschke ", "I kindly want to ask when this issue will be solved. \n\nMy working setup: Python 3.11.9 and pandas==2.0.3\nFailing on Python 3.13.2 and pandas==2.2.3\n\nThe \"Reproducible Example\" doesn't work for me at all, but the error message of my app is the same. Thus, I assume the same root cause." ]
2,159,336,569
57,662
Reader accept directory path with suffix check
closed
2024-02-28T16:18:24
2024-03-18T01:14:48
2024-03-18T01:14:48
https://github.com/pandas-dev/pandas/issues/57662
true
null
null
sciencecw
6
### Feature Type - [ ] Adding new functionality to pandas - [X] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description Most reader methods accept a directory. e.g. `pandas.read_parquet("/home/data/')` The default behavior goes through every file and subdirectory in the path, regardless of file type. This is inconvenient when the directory includes a single log or metadata txt file ### Feature Description When returning a list of files, filter by file suffix ### Alternative Solutions N./A ### Additional Context _No response_
[ "Enhancement", "IO Parquet", "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "Thanks for the request!\r\n\r\n> Most reader methods accept a directory. e.g. `pandas.read_parquet(\"/home/data/')`\r\n\r\nparquet does this because of partitioned parquet files, a single parquet \"file\" can be a directory on disk. pandas is not doing any directory walking itself. Are there other readers that do this?\r\n\r\nI'm opposed to using suffixes as information. They are common but not universal conventions.", "This enhancement should likely be made upstream in arrow, since arrow is doing the directory walking. Unfortunately, datasets in arrow currently recursively walk every file, even if you have 1 file that is not a valid parquet file. Perhaps instead of doing it based on extension, there should be a flag to skip any invalid parquet file in the directory, regardless of extension?", "I agree with @rohanjain101 \r\n\r\nI don't know any other reader doing this actually. I am not surprised this is an arrow issue. I second that skipping invalid file is a way forward", "@sciencecw it looks like pyarrow has this functionality already:\r\n\r\n```\r\n>>> from pyarrow import dataset\r\n>>> table = dataset.dataset(r\"/home/data/\", format=\"parquet\", exclude_invalid_files=True).to_table()\r\n>>> df = table.to_pandas()\r\n>>>\r\n```\r\n\r\nThis will skip invalid parquet files in the directory. I'm not sure if its possible to do this through pd.read_parquet directly though, since read_parquet in pandas just calls pa.parquet.read_table, and pa.parquet.read_table doesn't support this argument.", "Thanks @rohanjain101 looks like that is what I need", "closing then" ]
2,159,247,829
57,661
BUG: Transform() function returns unexpected results with list
open
2024-02-28T15:35:57
2024-02-29T22:23:30
null
https://github.com/pandas-dev/pandas/issues/57661
true
null
null
J-ZW-Wang
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd game = pd.DataFrame({ 'team' : ['A', 'A', 'B', 'B', 'C', 'C', 'C'], 'members' : [1, 2, 3, 4, 5, 6, 7] }) game['all_team_members'] = game.groupby('team').members.transform(lambda x : x.tolist()) game ``` ### Issue Description I would like to concatenate the values from column 'members' by group 'team' to form a list, and attach them to a new variable all_team_members. I got the following results: ``` team members all_team_members 0 A 1 1 1 A 2 2 2 B 3 3 3 B 4 4 4 C 5 5 5 C 6 6 6 C 7 7 ``` ### Expected Behavior The expected results are: ``` team members all_team_members 0 A 1 [1, 2] 1 A 2 [1, 2] 2 B 3 [3, 4] 3 B 4 [3, 4] 4 C 5 [5, 6, 7] 5 C 6 [5, 6, 7] 6 C 7 [5, 6, 7] ``` Note, `game.groupby('team').members.apply(lambda x : x.tolist())` worked as expected, so this problem is isolated to just the `transform()` function ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.5.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22631 machine : AMD64 processor : AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD byteorder : little LC_ALL : None LANG : None LOCALE : English_United States.1252 pandas : 2.2.1 numpy : 1.24.3 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 68.0.0 pip : 23.2.1 Cython : None pytest : 7.4.0 hypothesis : None sphinx : 5.0.2 blosc : None feather : None xlsxwriter : None lxml.etree : 4.9.3 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.15.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : 1.3.7 dataframe-api-compat : None fastparquet : None fsspec : 2023.4.0 gcsfs : None matplotlib : 3.7.2 numba : 0.57.1 numexpr : 2.8.4 odfpy : None openpyxl : None pandas_gbq : None pyarrow : 11.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : 2023.4.0 scipy : 1.11.1 sqlalchemy : None tables : 3.8.0 tabulate : None xarray : 2023.6.0 xlrd : None zstandard : 0.19.0 tzdata : 2023.3 qtpy : None pyqt5 : None </details>
[ "Bug", "Groupby", "Needs Discussion", "Transformations" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report. I agree this would be useful to have, but the trouble is in the inference of what to do with the result. `groupby.transform` can take methods that are transforms (return the same shape as the input) or reducers (return a scalar). When a User Defined Function (UDF) returns a list of the same length as the input as is the case here, how do we know which of the two the user desires?\r\n\r\nThe only option I see is to add an argument to transform, e.g. `is_reducer=[[False]|True]` or `is_reducer=[[\"infer\"]|True|False]` which provides the user control over how the result is interpreted. \r\n\r\nAnother option I've considered is to be very strict and require the UDF return a Series or DataFrame with an index the same as an input to be considered a transform, otherwise we assume it's a reducer. However I do not think this is a viable path - e.g. in the past we've recommended users use `.to_numpy()` if they wish to avoid transform's automatic alignment with the input, and this would be incompatible with that.\r\n\r\nYet another option would be to infer scalars (via pandas' `is_scalar`) and assume transform otherwise. This would notably not help the use case of the OP.", "Thank you for investigating this. I believe that, intuitively, the behavior of `groupby('x').y.transform()` should be consistent with that of `groupby('x').y.apply()`. When opting for `transform()` over `apply()`, users anticipate obtaining the same results from the groupby() aggregation, with the distinction that the original DataFrame's structure is preserved. It is expected that the newly created variable captures the **aggregate** outcomes for the elements within each group. Therefore, distributing these aggregated values across individual rows seems counterintuitive. Furthermore, the official documentation does not address this aspect of behavior within the context of groupby()\r\n\r\n", "> When opting for transform() over apply(), users anticipate obtaining the same results from the groupby() aggregation, with the distinction that the original DataFrame's structure is preserved. It is expected that the newly created variable captures the aggregate outcomes for the elements within each group.\r\n\r\nI think you also need to consider the use case of something like:\r\n\r\n df.groupby(...).transform(lambda x: x.cumsum())\r\n\r\nThat is, where `func` doesn't reduce but transforms. That is currently supported today, and it seems reasonable to me that users expect it to be supported." ]
2,158,910,643
57,660
BUG: to_sql fails for Oracle BLOB columns
open
2024-02-28T12:56:20
2025-07-15T20:43:36
null
https://github.com/pandas-dev/pandas/issues/57660
true
null
null
turbofart
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 ```sql create table attachment ( att_id number not null , att_contents blob not null ) ``` ```python import pandas as pd from sqlalchemy import create_engine, text as sql_text con_src = create_engine("oracle+oracledb://<username>:<password>@<source_database>") con_dst = create_engine("oracle+oracledb://<username>:<password>@<destination_database>") with con_src.connect() as conn: rd = pd.read_sql(sql=sql_text('select * from attachment'), con=conn) with con_dst.connect() as conn: rd.to_sql(name="attachment", con=conn, if_exists='append', index=False) ``` ### Issue Description ``` --------------------------------------------------------------------------- UnicodeDecodeError Traceback (most recent call last) Cell In[7], line 3 1 con_dst = eng_test 2 with con_dst.connect() as conn: ----> 3 rd.to_sql(name="attachment", con=conn, if_exists='append', index=False) File C:\dev\jupyter\venv\Lib\site-packages\pandas\util\_decorators.py:333, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs) 327 if len(args) > num_allow_args: 328 warnings.warn( 329 msg.format(arguments=_format_argument_list(allow_args)), 330 FutureWarning, 331 stacklevel=find_stack_level(), 332 ) --> 333 return func(*args, **kwargs) File C:\dev\jupyter\venv\Lib\site-packages\pandas\core\generic.py:3084, in NDFrame.to_sql(self, name, con, schema, if_exists, index, index_label, chunksize, dtype, method) 2886 """ 2887 Write records stored in a DataFrame to a SQL database. 2888 (...) 3080 [(1,), (None,), (2,)] 3081 """ # noqa: E501 3082 from pandas.io import sql -> 3084 return sql.to_sql( 3085 self, 3086 name, 3087 con, 3088 schema=schema, 3089 if_exists=if_exists, 3090 index=index, 3091 index_label=index_label, 3092 chunksize=chunksize, 3093 dtype=dtype, 3094 method=method, 3095 ) File C:\dev\jupyter\venv\Lib\site-packages\pandas\io\sql.py:842, in to_sql(frame, name, con, schema, if_exists, index, index_label, chunksize, dtype, method, engine, **engine_kwargs) 837 raise NotImplementedError( 838 "'frame' argument should be either a Series or a DataFrame" 839 ) 841 with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: --> 842 return pandas_sql.to_sql( 843 frame, 844 name, 845 if_exists=if_exists, 846 index=index, 847 index_label=index_label, 848 schema=schema, 849 chunksize=chunksize, 850 dtype=dtype, 851 method=method, 852 engine=engine, 853 **engine_kwargs, 854 ) File C:\dev\jupyter\venv\Lib\site-packages\pandas\io\sql.py:2018, in SQLDatabase.to_sql(self, frame, name, if_exists, index, index_label, schema, chunksize, dtype, method, engine, **engine_kwargs) 2006 sql_engine = get_engine(engine) 2008 table = self.prep_table( 2009 frame=frame, 2010 name=name, (...) 2015 dtype=dtype, 2016 ) -> 2018 total_inserted = sql_engine.insert_records( 2019 table=table, 2020 con=self.con, 2021 frame=frame, 2022 name=name, 2023 index=index, 2024 schema=schema, 2025 chunksize=chunksize, 2026 method=method, 2027 **engine_kwargs, 2028 ) 2030 self.check_case_sensitive(name=name, schema=schema) 2031 return total_inserted File C:\dev\jupyter\venv\Lib\site-packages\pandas\io\sql.py:1558, in SQLAlchemyEngine.insert_records(self, table, con, frame, name, index, schema, chunksize, method, **engine_kwargs) 1555 from sqlalchemy import exc 1557 try: -> 1558 return table.insert(chunksize=chunksize, method=method) 1559 except exc.StatementError as err: 1560 # GH34431 1561 # https://stackoverflow.com/a/67358288/6067848 1562 msg = r"""(\(1054, "Unknown column 'inf(e0)?' in 'field list'"\))(?# 1563 )|inf can not be used with MySQL""" File C:\dev\jupyter\venv\Lib\site-packages\pandas\io\sql.py:1119, in SQLTable.insert(self, chunksize, method) 1116 break 1118 chunk_iter = zip(*(arr[start_i:end_i] for arr in data_list)) -> 1119 num_inserted = exec_insert(conn, keys, chunk_iter) 1120 # GH 46891 1121 if num_inserted is not None: File C:\dev\jupyter\venv\Lib\site-packages\pandas\io\sql.py:1010, in SQLTable._execute_insert(self, conn, keys, data_iter) 998 """ 999 Execute SQL statement inserting data 1000 (...) 1007 Each item contains a list of values to be inserted 1008 """ 1009 data = [dict(zip(keys, row)) for row in data_iter] -> 1010 result = conn.execute(self.table.insert(), data) 1011 return result.rowcount File C:\dev\jupyter\venv\Lib\site-packages\sqlalchemy\engine\base.py:1416, in Connection.execute(self, statement, parameters, execution_options) 1414 raise exc.ObjectNotExecutableError(statement) from err 1415 else: -> 1416 return meth( 1417 self, 1418 distilled_parameters, 1419 execution_options or NO_OPTIONS, 1420 ) File C:\dev\jupyter\venv\Lib\site-packages\sqlalchemy\sql\elements.py:516, in ClauseElement._execute_on_connection(self, connection, distilled_params, execution_options) 514 if TYPE_CHECKING: 515 assert isinstance(self, Executable) --> 516 return connection._execute_clauseelement( 517 self, distilled_params, execution_options 518 ) 519 else: 520 raise exc.ObjectNotExecutableError(self) File C:\dev\jupyter\venv\Lib\site-packages\sqlalchemy\engine\base.py:1639, in Connection._execute_clauseelement(self, elem, distilled_parameters, execution_options) 1627 compiled_cache: Optional[CompiledCacheType] = execution_options.get( 1628 "compiled_cache", self.engine._compiled_cache 1629 ) 1631 compiled_sql, extracted_params, cache_hit = elem._compile_w_cache( 1632 dialect=dialect, 1633 compiled_cache=compiled_cache, (...) 1637 linting=self.dialect.compiler_linting | compiler.WARN_LINTING, 1638 ) -> 1639 ret = self._execute_context( 1640 dialect, 1641 dialect.execution_ctx_cls._init_compiled, 1642 compiled_sql, 1643 distilled_parameters, 1644 execution_options, 1645 compiled_sql, 1646 distilled_parameters, 1647 elem, 1648 extracted_params, 1649 cache_hit=cache_hit, 1650 ) 1651 if has_events: 1652 self.dispatch.after_execute( 1653 self, 1654 elem, (...) 1658 ret, 1659 ) File C:\dev\jupyter\venv\Lib\site-packages\sqlalchemy\engine\base.py:1848, in Connection._execute_context(self, dialect, constructor, statement, parameters, execution_options, *args, **kw) 1843 return self._exec_insertmany_context( 1844 dialect, 1845 context, 1846 ) 1847 else: -> 1848 return self._exec_single_context( 1849 dialect, context, statement, parameters 1850 ) File C:\dev\jupyter\venv\Lib\site-packages\sqlalchemy\engine\base.py:1988, in Connection._exec_single_context(self, dialect, context, statement, parameters) 1985 result = context._setup_result_proxy() 1987 except BaseException as e: -> 1988 self._handle_dbapi_exception( 1989 e, str_statement, effective_parameters, cursor, context 1990 ) 1992 return result File C:\dev\jupyter\venv\Lib\site-packages\sqlalchemy\engine\base.py:2346, in Connection._handle_dbapi_exception(self, e, statement, parameters, cursor, context, is_sub_exec) 2344 else: 2345 assert exc_info[1] is not None -> 2346 raise exc_info[1].with_traceback(exc_info[2]) 2347 finally: 2348 del self._reentrant_error File C:\dev\jupyter\venv\Lib\site-packages\sqlalchemy\engine\base.py:1969, in Connection._exec_single_context(self, dialect, context, statement, parameters) 1967 break 1968 if not evt_handled: -> 1969 self.dialect.do_execute( 1970 cursor, str_statement, effective_parameters, context 1971 ) 1973 if self._has_events or self.engine._has_events: 1974 self.dispatch.after_cursor_execute( 1975 self, 1976 cursor, (...) 1980 context.executemany, 1981 ) File C:\dev\jupyter\venv\Lib\site-packages\sqlalchemy\engine\default.py:922, in DefaultDialect.do_execute(self, cursor, statement, parameters, context) 921 def do_execute(self, cursor, statement, parameters, context=None): --> 922 cursor.execute(statement, parameters) File C:\dev\jupyter\venv\Lib\site-packages\oracledb\cursor.py:382, in Cursor.execute(self, statement, parameters, **keyword_parameters) 380 self._set_input_sizes = False 381 if parameters is not None: --> 382 impl.bind_one(self, parameters) 383 impl.execute(self) 384 if impl.fetch_vars is not None: File src\\oracledb\\impl/base/cursor.pyx:391, in oracledb.base_impl.BaseCursorImpl.bind_one() File src\\oracledb\\impl/base/cursor.pyx:57, in oracledb.base_impl.BaseCursorImpl._bind_values() File src\\oracledb\\impl/base/cursor.pyx:98, in oracledb.base_impl.BaseCursorImpl._bind_values_by_name() File src\\oracledb\\impl/base/bind_var.pyx:130, in oracledb.base_impl.BindVar._set_by_value() File src\\oracledb\\impl/base/var.pyx:86, in oracledb.base_impl.BaseVarImpl._check_and_set_value() File src\\oracledb\\impl/base/var.pyx:59, in oracledb.base_impl.BaseVarImpl._check_and_set_scalar_value() File src\\oracledb\\impl/base/connection.pyx:76, in oracledb.base_impl.BaseConnImpl._check_value() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 10: invalid continuation byte ``` ### Expected Behavior Rows are successfully inserted into the table. ### Installed Versions ``` INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.0.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19045 machine : AMD64 processor : Intel64 Family 6 Model 85 Stepping 4, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : English_Switzerland.1252 pandas : 2.2.1 numpy : 1.26.2 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 69.0.2 pip : 24.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.18.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2023.10.0 gcsfs : None matplotlib : 3.8.2 numba : None numexpr : None odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.11.4 sqlalchemy : 2.0.23 tables : None tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2023.3 qtpy : None pyqt5 : None ```
[ "Bug", "IO SQL", "Needs Triage" ]
0
0
0
0
0
0
0
1
[]
2,158,097,714
57,659
ENH: DataFrame.duplicated() should have default `keep` parameter as False
closed
2024-02-28T04:44:05
2024-03-12T05:29:06
2024-03-12T05:29:06
https://github.com/pandas-dev/pandas/issues/57659
true
null
null
jackmappotion
1
### Feature Type - [X] Changing existing functionality in pandas ### Problem Description `df.duplicated()` should return all of duplicates in my opinion. Default parameter is now `first` but I think it's not proper. ### Feature Description ``` def duplicated( self, subset: Hashable | Sequence[Hashable] | None = None, keep: DropKeep = "first", ) -> Series: ... ``` ### Alternative Solutions ``` def duplicated( self, subset: Hashable | Sequence[Hashable] | None = None, keep: DropKeep = False, ) -> Series: ... ``` ### Additional Context I made pull request, but I just closed it. Need discussions!
[ "Enhancement", "Needs Discussion", "duplicated" ]
0
0
0
0
0
0
0
0
[ "Thanks for the request. Given the list `[1, 1, 1]`, it seems to me one can argue that either all three values or just the 2nd and 3rd values are duplicates. Depending on which stance you take determines what you think `df.duplicated()` should do by default. If it is indeed a matter of opinion, then I think we should maintain the status quo and not induce code churn by changing the default.\r\n\r\nIf it can be shown that similar libraries have a corresponding method which (fairly) consistently default to the equivalent of `keep=False`, then that would be a more compelling case that pandas should change." ]
2,158,057,240
57,658
FIX: fix default argument of duplicated
closed
2024-02-28T04:10:02
2024-02-28T04:17:38
2024-02-28T04:17:38
https://github.com/pandas-dev/pandas/pull/57658
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57658
https://github.com/pandas-dev/pandas/pull/57658
jackmappotion
1
`df.duplicated(keep=False)` Should have default `keep` parameter as `False` It's proper result for `df.duplicated()` to show all duplicates. - [ ] 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
[ "Requirements are not satisfied." ]
2,158,019,835
57,657
Fixing bug_ 57596
closed
2024-02-28T03:26:37
2024-03-18T01:28:24
2024-03-18T01:28:23
https://github.com/pandas-dev/pandas/pull/57657
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57657
https://github.com/pandas-dev/pandas/pull/57657
SoumyaSri1998
2
- [x] closes #57596 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/v2.2.1.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix", "please always add tests and make sure the new tests pass before opening prs, this won't have any effect" ]
2,157,914,211
57,656
BUG: groupby.apply respects as_index=False if and only if group_keys=True
open
2024-02-28T01:41:57
2024-03-01T22:43:00
null
https://github.com/pandas-dev/pandas/issues/57656
true
null
null
mvashishtha
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd df = pd.DataFrame({'A': [7, -1, 4, 5], 'B': [10, 4, 2, 8]}, index= pd.Index(['i3', 'i2', 'i1', 'i0'], name='i0')) ################################ # For transforms, like lambda x: x ################################ # when group_keys=True, apply() respects as_index=False. same is true when grouping by 'i0' or by ['i0', 'A'] print(df.groupby('A', as_index=True, group_keys=True).apply(lambda x: x, include_groups=False)) print(df.groupby('A', as_index=False, group_keys=True).apply(lambda x: x, include_groups=False)) # when group_keys=False, apply() does not respect as_index=False. same is true when grouping by 'i0' or by ['i0', 'A'] print(df.groupby('A', as_index=True, group_keys=False).apply(lambda x: x, include_groups=False)) print(df.groupby('A', as_index=False, group_keys=False).apply(lambda x: x, include_groups=False)) ################################ # For non-transform lambda x: pd.DataFrame([x.iloc[0].sum()]) ################################ # when group_keys=True, grouping by data column respects as_index=False. same is true when grouping by 'i0' or by ['i0', 'A'] print(df.groupby('A', as_index=True, group_keys=True).apply(lambda x: pd.DataFrame([x.iloc[0].sum()]), include_groups=False)) print(df.groupby('A', as_index=False, group_keys=True).apply(lambda x: pd.DataFrame([x.iloc[0].sum()]), include_groups=False)) # when group_keys=False, grouping by data column does not respect as_index=False. same is true when grouping by 'i0' or by ['i0', 'A'] print(df.groupby('A', as_index=True, group_keys=False).apply(lambda x: pd.DataFrame([x.iloc[0].sum()]), include_groups=False)) print(df.groupby('A', as_index=False, group_keys=False).apply(lambda x: pd.DataFrame([x.iloc[0].sum()]), include_groups=False)) ``` ### Issue Description groupby.apply respects as_index=False if and only if `group_keys=True`, but the documentation suggests that it should only respect `as_index` if `group_keys=False`. My apologies in advance if I'm duplicating an issue or misunderstanding the intended behavior here. I know there has been some relevant discussion in #49543. ### Expected Behavior I don't know what the correct behavior is here. A simple and easily explainable behavior would be to always respect `as_index=False`. However, to be consistent with the documentation [here](https://pandas.pydata.org/pandas-docs/stable/user_guide/groupby.html#transformation), transform-like applies should never respect `as_index=False`, and I suppose that non-transform-like applies should respect it: > Since transformations do not include the groupings that are used to split the result, the arguments as_index and sort in [DataFrame.groupby()](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html#pandas.DataFrame.groupby) and [Series.groupby()](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.groupby.html#pandas.Series.groupby) have no effect. When `group_keys=True`, the result **does** include the "groupings that are used to split the result", so for the same reason that this note gives, `as_index` should have no effect. The current behavior is the opposite, though: `as_index` has an effect only when `group_keys=True`. (despite the description of [group_keys](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.groupby.html), it appears that `apply` includes the group keys in the index if and only if `group_keys=False`, regardless of whether `func` is a transform.) ### 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 : None LANG : en_US.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 : None IPython : 8.18.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None ``` </details>
[ "Bug", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "`sort` interaction with `group_keys` is also confusing, but different: ~for transforms, we only sort if `sort=True, group_keys=True`, and in particular we do **not** sort if `sort=True, group_keys=False`.~ For non-transforms, `apply()` sorts if `sort=True`, regardless of the value of `group_keys`.\r\n\r\n```python\r\nimport pandas as pd\r\n\r\ndf = pd.DataFrame({'A': [7, -1, 4, 5], 'B': [10, 4, 2, 8]}, index= pd.Index(['i3', 'i2', 'i1', 'i0'], name='i0'))\r\n\r\n################################\r\n# For transforms, like lambda x: x\r\n################################\r\n\r\n# when group_keys=True, apply() sorts if and only if sort=True as well.\r\nprint(df.groupby('A', sort=True, group_keys=True).apply(lambda x: x, include_groups=False))\r\nprint(df.groupby('A', sort=False, group_keys=True).apply(lambda x: x, include_groups=False))\r\n\r\n# when group_keys=False, never sort.\r\nprint(df.groupby('A', sort=True, group_keys=False).apply(lambda x: x, include_groups=False))\r\nprint(df.groupby('A', sort=False, group_keys=False).apply(lambda x: x, include_groups=False))\r\n\r\n################################\r\n# For non-transform lambda x: pd.DataFrame([x.iloc[0].sum()])\r\n################################\r\n\r\n# when group_keys=True, apply() respects sort=True and sort=False.\r\nprint(df.groupby('A', sort=True, group_keys=True).apply(lambda x: pd.DataFrame([x.iloc[0].sum()]), include_groups=False))\r\nprint(df.groupby('A', sort=False, group_keys=True).apply(lambda x: pd.DataFrame([x.iloc[0].sum()]), include_groups=False))\r\n\r\n# when group_keys=False, apply() respects sort=True and sort=False.\r\nprint(df.groupby('A', sort=True, group_keys=False).apply(lambda x: pd.DataFrame([x.iloc[0].sum()]), include_groups=False))\r\nprint(df.groupby('A', sort=False, group_keys=False).apply(lambda x: pd.DataFrame([x.iloc[0].sum()]), include_groups=False))\r\n```\r\n\r\nedit: see below for comment about `sort` behavior for transforms under `group_keys=True` and `group_keys=False`.", "correction for `sort` behavior of transforms:\r\n\r\nRather than following following the usual interpretation of either sort=True or sort=False, it seems that when `group_keys=False`, we reindex back to the original dataframe order. so we return a dataframe with the same exact index as the original. OTOH, when group_keys=True, sort=True really means sort=True, and sort=False really means sort=False. My above examples don't capture this because the keys are unique. but this does:\r\n\r\n```python\r\nimport pandas as pd\r\n\r\ndf = pd.DataFrame({'A': [7, -1, 4, 7], 'B': [10, 4, 2, 8]}, index= pd.Index(['i3', 'i2', 'i1', 'i0'], name='i0'))\r\n\r\n################################\r\n# For transforms, like lambda x: x\r\n################################\r\n\r\n# when group_keys=True, sort means the usual thing: sort = True means sort by values of group keys. sort = False\r\n# means sort by order of appearance of group keys.\r\nprint(df.groupby('A', sort=True, group_keys=True).apply(lambda x: x, include_groups=False))\r\nprint(df.groupby('A', sort=False, group_keys=True).apply(lambda x: x, include_groups=False))\r\n\r\n# when group_keys=False, reindex result to the index of the original dataframe. sort param has no effect.\r\nprint(df.groupby('A', sort=True, group_keys=False).apply(lambda x: x, include_groups=False))\r\nprint(df.groupby('A', sort=False, group_keys=False).apply(lambda x: x, include_groups=False))\r\n```", "@mvashishtha - would you be able to condense this back into the OP?" ]
2,157,811,429
57,655
CLN: Enforce deprecation of using alias for builtin/NumPy funcs (#57444)
closed
2024-02-27T23:51:12
2024-02-28T17:32:33
2024-02-28T17:32:32
https://github.com/pandas-dev/pandas/pull/57655
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57655
https://github.com/pandas-dev/pandas/pull/57655
Chisholm6192
1
* CLN: Enforce deprecation of using alias for builtin/NumPy funcs * GH# and whatsnew * Fixup docs * More tests * Restore docstring * Test fixes * Test fixups * Test fixes * Test fixup * Test fixes - [ ] 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
[ "This PR contents doesn't seem to match what's described here so closing" ]
2,157,760,022
57,654
REF: simplify pytables _set_tz
closed
2024-02-27T23:01:49
2024-02-28T00:39:40
2024-02-28T00:25:21
https://github.com/pandas-dev/pandas/pull/57654
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57654
https://github.com/pandas-dev/pandas/pull/57654
jbrockmendel
1
yak-shaving aimed at pieces of the Ice Cream Agreement.
[ "IO HDF5", "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @jbrockmendel " ]
2,157,708,901
57,653
CLN: unify error message when parsing datetimes with mixed time zones with utc=False
closed
2024-02-27T22:18:28
2024-02-28T16:42:18
2024-02-28T16:42:10
https://github.com/pandas-dev/pandas/pull/57653
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57653
https://github.com/pandas-dev/pandas/pull/57653
natmokval
1
xref #57275, #55793 unified ValueError message when parsing datetimes with mixed time zones with utc=False so far we get two different ValueError messages: ``` import pandas as pd from datetime import datetime import pytz str_my ="2020-10-26 00:00:00+06:00" ts = pd.Timestamp("2018-01-01", tz="US/Pacific") dt = datetime(2020, 1, 1, 18, tzinfo=pytz.timezone("Australia/Melbourne")) dt1 = pd.to_datetime([ts, str_my]) # ValueError: Mixed timezones detected. pass utc=True in to_datetime or tz='UTC' in DatetimeIndex to convert to a common timezone. dt2 = pd.to_datetime([str_my, ts]) # ValueError: cannot parse datetimes with mixed time zones unless `utc=True` dt1 = pd.to_datetime([dt, str_my], utc=False) # ValueError: Mixed timezones detected. pass utc=True in to_datetime or tz='UTC' in DatetimeIndex to convert to a common timezone. dt2 = pd.to_datetime([str_my, dt], utc=False) # ValueError: cannot parse datetimes with mixed time zones unless `utc=True` ```
[ "Error Reporting", "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @natmokval " ]
2,157,688,039
57,652
TST: fix test_complibs on mac
closed
2024-02-27T22:03:16
2024-02-28T00:40:01
2024-02-27T23:24:40
https://github.com/pandas-dev/pandas/pull/57652
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57652
https://github.com/pandas-dev/pandas/pull/57652
jbrockmendel
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.
[ "Testing", "OS X" ]
0
0
0
0
0
0
0
0
[ "Thanks @jbrockmendel " ]
2,157,516,937
57,651
PERF: Return RangeIndex from RangeIndex.join when possible
closed
2024-02-27T20:08:44
2024-03-05T00:58:01
2024-03-05T00:57:57
https://github.com/pandas-dev/pandas/pull/57651
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57651
https://github.com/pandas-dev/pandas/pull/57651
mroeschke
1
Discovered in https://github.com/pandas-dev/pandas/pull/57441
[ "Performance", "Index" ]
0
0
0
0
0
0
0
0
[ "Going to merge this one. Happy to follow up if needed" ]
2,157,343,297
57,650
BUG: integers are being converted to floats when accessed from DataFrame
closed
2024-02-27T18:30:13
2024-02-27T18:56:20
2024-02-27T18:56:20
https://github.com/pandas-dev/pandas/issues/57650
true
null
null
Poly-Mentor
1
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd print(pd.__version__) # 2.2.1 ``` I create DF with floats and ints, making sure ints are ints by eforcing dtype: ```python df = pd.DataFrame( {"number" : [1.2345, 1.2345, 1.2345], "precision" : pd.Series([2, 3, 4], dtype="int8")}) print(f"{df=} \n") print(f"{df['precision']=} \n") ``` ``` df= number precision 0 1.2345 2 1 1.2345 3 2 1.2345 4 df['precision']=0 2 1 3 2 4 Name: precision, dtype: int8 ``` Seems to be ok, for column 'precision' dtype is int8 But when I try to access it: ```python for index, row in df.iterrows(): x = row["precision"] print(f"{x=}, {x.dtype=}, {type(x)=}") ``` I get floats returned ``` x=2.0, x.dtype=dtype('float64'), type(x)=<class 'numpy.float64'> x=3.0, x.dtype=dtype('float64'), type(x)=<class 'numpy.float64'> x=4.0, x.dtype=dtype('float64'), type(x)=<class 'numpy.float64'> ``` ### Issue Description Inbetween creating DataFrame with Series of integers, they somehow get converted to floats when accessed by DataFrame's .iterrows() method. I encountered the problem trying to generate formatted strings with defined precision (different for each row) from floating point numbers. More visually, I tried to go from this: ``` df= number precision 0 1.2345 2 1 1.2345 3 2 1.2345 4 ``` to this: ``` number precision formatted 0 1.2345 2 1.23 1 1.2345 3 1.234 2 1.2345 4 1.2345 ``` i tried to use this code: ```python df["formatted"] = df.apply(lambda x: "{number:.{sig_fig}f}".format(sig_fig=x["precision"], number=x["number"]), axis=1) ``` but it gave an error: ```python-traceback --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[22], [line 1](vscode-notebook-cell:?execution_count=22&line=1) ----> [1](vscode-notebook-cell:?execution_count=22&line=1) df["formatted"] = df.apply(lambda x: "{number:.{sig_fig}f}".format(sig_fig=x["precision"], number=x["number"]), axis=1) File [~\AppData\Roaming\Python\Python312\site-packages\pandas\core\frame.py:10361](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/frame.py:10361), in DataFrame.apply(self, func, axis, raw, result_type, args, by_row, engine, engine_kwargs, **kwargs) [10347](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/frame.py:10347) from pandas.core.apply import frame_apply [10349](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/frame.py:10349) op = frame_apply( [10350](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/frame.py:10350) self, [10351](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/frame.py:10351) func=func, (...) [10359](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/frame.py:10359) kwargs=kwargs, [10360](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/frame.py:10360) ) > [10361](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/frame.py:10361) return op.apply().__finalize__(self, method="apply") File [~\AppData\Roaming\Python\Python312\site-packages\pandas\core\apply.py:916](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:916), in FrameApply.apply(self) [913](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:913) elif self.raw: [914](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:914) return self.apply_raw(engine=self.engine, engine_kwargs=self.engine_kwargs) --> [916](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:916) return self.apply_standard() File [~\AppData\Roaming\Python\Python312\site-packages\pandas\core\apply.py:1063](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1063), in FrameApply.apply_standard(self) [1061](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1061) def apply_standard(self): [1062](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1062) if self.engine == "python": -> [1063](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1063) results, res_index = self.apply_series_generator() [1064](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1064) else: [1065](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1065) results, res_index = self.apply_series_numba() File [~\AppData\Roaming\Python\Python312\site-packages\pandas\core\apply.py:1081](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1081), in FrameApply.apply_series_generator(self) [1078](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1078) with option_context("mode.chained_assignment", None): [1079](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1079) for i, v in enumerate(series_gen): [1080](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1080) # ignore SettingWithCopy here in case the user mutates -> [1081](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1081) results[i] = self.func(v, *self.args, **self.kwargs) [1082](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1082) if isinstance(results[i], ABCSeries): [1083](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1083) # If we have a view on v, we need to make a copy because [1084](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1084) # series_generator will swap out the underlying data [1085](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/filip/Documents/dev/~/AppData/Roaming/Python/Python312/site-packages/pandas/core/apply.py:1085) results[i] = results[i].copy(deep=False) Cell In[22], [line 1](vscode-notebook-cell:?execution_count=22&line=1) ----> [1](vscode-notebook-cell:?execution_count=22&line=1) df["formatted"] = df.apply(lambda x: "{number:.{sig_fig}f}".format(sig_fig=x["precision"], number=x["number"]), axis=1) ValueError: Invalid format specifier '.2.0f' for object of type 'float' ``` It's because an integer (2 in this example) was returned as a float, when lambda function accesed it. Shortly, this ```python x["precision"] ``` was expected to be 2 (int), but it's 2.0 (float). When I make change and convert it to int, the line works and give expected output. ```python df["formatted"] = df.apply(lambda x: "{number:.{sig_fig}f}".format(sig_fig=int(x["precision"]), number=x["number"]), axis=1) print(df) ''' number precision formatted 0 1.2345 2 1.23 1 1.2345 3 1.234 2 1.2345 4 1.2345 ''' ``` I found that I can recreate that behavior when using pd.df.iterrows() instead of .apply(), and that's the way I showed it in minimal example, but I also describe my use-case to show, that not just iterrows method is giving this unexpected result. I'm new to pandas, so I don't know if it's really a bug, but for me it works different that I would expect. ### Expected Behavior When I create DataFrame with single Series: ```python df2 = pd.DataFrame( {"precision" : pd.Series([2, 3, 4], dtype="int8")}) ``` I get expected output: ```python for index, row in df2.iterrows(): x = row["precision"] print(f"{x=}, {x.dtype=}, {type(x)=}") ``` ``` x=2, x.dtype=dtype('int8'), type(x)=<class 'numpy.int8'> x=3, x.dtype=dtype('int8'), type(x)=<class 'numpy.int8'> x=4, x.dtype=dtype('int8'), type(x)=<class 'numpy.int8'> ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.12.2.final.0 python-bits : 64 OS : Windows OS-release : 11 Version : 10.0.22631 machine : AMD64 processor : AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD byteorder : little LC_ALL : None LANG : None LOCALE : Polish_Poland.1250 pandas : 2.2.1 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : None pip : 24.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.22.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 : 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 None </details>
[ "Bug", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report but this is the expected behavior. `iterrows` creates a `Series` from each row and needs to find a common type between the `float64` of `number` and `int8` of `precision` which is `float64`. This is the equivalent behavior\r\n\r\n```python\r\nIn [5]: import pandas as pd\r\n\r\nIn [6]: import numpy as np\r\n\r\nIn [7]: pd.Series([np.float64(2.5), np.int8(1)])\r\nOut[7]: \r\n0 2.5\r\n1 1.0\r\ndtype: float64\r\n```\r\n\r\nIn order not to lose the decimal portion of the floats, the common type is `float64`. Closing as a usage question " ]
2,157,305,973
57,649
DOC: RT03 fix for read_sql_query, read_feather
closed
2024-02-27T18:09:11
2024-02-28T16:41:16
2024-02-28T16:41:09
https://github.com/pandas-dev/pandas/pull/57649
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57649
https://github.com/pandas-dev/pandas/pull/57649
YashpalAhlawat
1
- [x] xref #57416 (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. - [ ] 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 @YashpalAhlawat " ]
2,157,296,981
57,648
DOC: Add clarification to groupby docs regarding hashes and equality
closed
2024-02-27T18:03:37
2024-03-06T21:48:13
2024-03-06T21:48:04
https://github.com/pandas-dev/pandas/pull/57648
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57648
https://github.com/pandas-dev/pandas/pull/57648
gabuzi
3
closes #57526
[ "Docs", "Groupby" ]
0
0
0
0
0
0
0
0
[ "@gabuzi do you have time to address the comments from the review?", "> @gabuzi do you have time to address the comments from the review?\r\n\r\nYes, thanks for the ping.\r\n", "Thanks @gabuzi!" ]
2,157,247,067
57,647
PERF: Return RangeIndex from RangeIndex.reindex when possible
closed
2024-02-27T17:33:32
2024-03-05T23:03:36
2024-03-05T23:03:34
https://github.com/pandas-dev/pandas/pull/57647
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57647
https://github.com/pandas-dev/pandas/pull/57647
mroeschke
2
Discovered in https://github.com/pandas-dev/pandas/pull/57441
[ "Performance", "Index" ]
0
0
0
0
0
0
0
0
[ "I think something went wrong with git here, feels like this have unrelated changes, right?", "As of 1a122350fd9acab946099d3a3e990b8a2af9b661, I think the diff against main should be minimal to the changes now. (In 370d20cb0ca46009c439e1dc9d6e805196df5271 I merged upstream incorrectly)" ]
2,156,976,927
57,646
BUG: Change output returned by _LocIndexer._convert_to_indexer to return key with greater resolution value
closed
2024-02-27T15:59:38
2024-03-20T17:24:38
2024-03-20T17:24:38
https://github.com/pandas-dev/pandas/pull/57646
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57646
https://github.com/pandas-dev/pandas/pull/57646
wleong1
1
Resolution info: **Resolution.RESO_SEC - 3 for seconds** **Resolution.RESO_MIN - 4 for minute** Observation: With the previous code, when the current entry (**resolution: 4, entry: '2024-02-24 10:08'**) has a greater resolution value than the smallest amongst previous entries (in this case **resolution: 3, entry: '2024-02-24 10:2:30'**), it is shown that the key is said to exist within the list of keys within the Series even though it shouldn't. This does not happen when a smaller or equal resolution value entry is inserted into the Series. ![Screenshot from 2024-02-26 13-14-10](https://github.com/pandas-dev/pandas/assets/122815453/0ec3fc4d-4831-47ac-9c19-c8b8fdbbaea9) Thought process: With the previous code, if the current entry's resolution value is greater than the smallest resolution value amongst the previous entries, the *_LocIndexer._convert_to_indexer* method will only return an empty list (output of the method *labels.get_loc(key)*), which might be causing entries with larger resolution values not being inserted into the *Series* correctly. Potential solution: I have changed the method *_LocIndexer._convert_to_indexer* to return the key ('2024-02-24 10:08') instead of an empty list when the resolution value is greater than the smallest resolution value. - [x] closes #57596 - [ ] [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/v2.2.1.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,156,764,658
57,645
BUG: Cannot use numpy FLS as indicies since pandas 2.2.1
open
2024-02-27T14:38:26
2025-06-02T17:15:57
null
https://github.com/pandas-dev/pandas/issues/57645
true
null
null
jday1
7
### 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 # List of fixed-length strings fixed_strings = ["apple", "banana", "orange", "grape"] # Define the fixed length for the strings string_length = 6 # Adjust as needed # Create NumPy array of fixed-length strings arr = np.array(fixed_strings, dtype=f"S{string_length}") df = pd.DataFrame(pd.Series(arr), columns=["fruit"]) # Raises NotImplementedError: |S6 df.set_index("fruit", inplace=True) ``` ### Issue Description The issue shown in the provided code is that when attempting to set the index of the Pandas DataFrame using `df.set_index("fruit", inplace=True)`, a `NotImplementedError` is raised with the message `|S6`. The reason for this error is that the dtype `|S6` is not supported as an index type in Pandas. When you create a NumPy array with a dtype of fixed-length strings using np.array() and attempt to set it as an index in a DataFrame, Pandas tries to convert it to a suitable index type, but `|S6` is not recognized as a valid option for the index. This is applicable to all `S` dtypes. The offending logic was introduced in pandas 2.2.1 by these lines of this commit: https://github.com/pandas-dev/pandas/commit/b6fb90574631c84f19f2dbdc68c26d6ce97446b4#diff-fb8a9c322624b0777f3ff7e3ef8320d746b15a2a0b80b7cab3dfbe2e12e06daaR239-R240 The code works as expected in pandas 2.2.0. ### Expected Behavior What happens when using 2.2.0: ``` import numpy as np import pandas as pd # List of fixed-length strings fixed_strings = ["apple", "banana", "orange", "grape"] # Define the fixed length for the strings string_length = 6 # Adjust as needed # Create NumPy array of fixed-length strings arr = np.array(fixed_strings, dtype=f"S{string_length}") df = pd.DataFrame(pd.Series(arr), columns=["fruit"]) df.set_index("fruit", inplace=True) print(df) ``` Prints: ``` Empty DataFrame Columns: [] Index: [b'apple', b'banana', b'orange', b'grape'] ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.1.final.0 python-bits : 64 OS : Linux OS-release : 6.6.10-76060610-generic Version : #202401051437~1704728131~22.04~24d69e2 SMP PREEMPT_DYNAMIC Mon J machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_GB.UTF-8 LOCALE : en_GB.UTF-8 pandas : 2.2.1 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 67.7.2 pip : 24.0 Cython : None pytest : 7.4.4 hypothesis : None sphinx : None blosc : None feather : 0.4.1 xlsxwriter : None lxml.etree : 4.9.3 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.15.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2023.10.0 gcsfs : None matplotlib : 3.8.3 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : 2023.10.0 scipy : 1.12.0 sqlalchemy : 2.0.20 tables : 3.9.2 tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2023.3 qtpy : None pyqt5 : None None </details>
[ "Bug", "Regression", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "cc @phofl", "take", "pandas does not support NumPy fixed length strings. Does this exhibit the same issue when you use the object dtype?", "Using 'object' dtype on the array creation works correctly. However pandas 2.2.1 brought a change to how 'S' dtype arrays were handled during Index creation, no longer automatically converting them to 'object' dtype. Shouldn't this functionality still be implemented? ", "Is that behavior documented somewhere? if not then no...I'd say its not worth doing too much here. We have never offered support for fixed length NumPy strings. `object` has been the historically supported data type, but we also now have \"string\", \"string[pyarrow]\" and \"string[pyarrow_numpy]` and maybe even a NumPy native string in the future. I don't see fixed length string support as something worth additionally investing in", "it should convert automatically to object, you should never end up with numpy fixed length strings", "In the commit previously mentioned in the issue description, the if statement:\r\n```\r\n elif isinstance(values, ABCSeries):\r\n return values._values\r\n```\r\n\r\nwas added to this function in the file pandas/core/common.py\r\n \r\n \r\n```\r\ndef asarray_tuplesafe(values: Iterable, dtype: NpDtype | None = None) -> ArrayLike:\r\n if not (isinstance(values, (list, tuple)) or hasattr(values, \"__array__\")):\r\n values = list(values)\r\n elif isinstance(values, ABCIndex):\r\n return values._values\r\n elif isinstance(values, ABCSeries):\r\n return values._values\r\n\r\n if isinstance(values, list) and dtype in [np.object_, object]:\r\n return construct_1d_object_array_from_listlike(values)\r\n\r\n try:\r\n with warnings.catch_warnings():\r\n # Can remove warning filter once NumPy 1.24 is min version\r\n if not np_version_gte1p24:\r\n warnings.simplefilter(\"ignore\", np.VisibleDeprecationWarning)\r\n result = np.asarray(values, dtype=dtype)\r\n except ValueError:\r\n # Using try/except since it's more performant than checking is_list_like\r\n # over each element\r\n # error: Argument 1 to \"construct_1d_object_array_from_listlike\"\r\n # has incompatible type \"Iterable[Any]\"; expected \"Sized\"\r\n return construct_1d_object_array_from_listlike(values) # type: ignore[arg-type]\r\n\r\n if issubclass(result.dtype.type, str):\r\n result = np.asarray(values, dtype=object)\r\n\r\n if result.ndim == 2:\r\n # Avoid building an array of arrays:\r\n values = [tuple(x) for x in values]\r\n result = construct_1d_object_array_from_listlike(values)\r\n\r\n return result\r\n```\r\n \r\nIt seems that with the addition of that if statement, any variable **values** that is of the type **series** will result in a true statement and return **values._values** without checking its content , this way not creating an array with the dtype **object** as it used to. Would something like this be an acceptable solution?.\r\n\r\n```\r\n elif isinstance(values, ABCSeries) and values._values.dtype.kind != \"S\"\r\n return values._values\r\n```\r\n" ]
2,156,706,986
57,644
BUG: differing syntax for datetime column dtype specification causes failure with `assert_frame_equal()`
closed
2024-02-27T14:12:46
2024-02-29T22:31:56
2024-02-29T22:31:51
https://github.com/pandas-dev/pandas/issues/57644
true
null
null
EsmeMaxwell
3
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python import pandas as pd import numpy as np from zoneinfo import ZoneInfo # Create two identical dataframes dates = pd.date_range("1/1/2000", periods=5, name="Date") df = pd.DataFrame(np.ones((5, 3)), index=dates, columns=["A", "B", "C"]) df2 = pd.DataFrame(np.ones((5, 3)), index=dates, columns=["A", "B", "C"]) # Add a datetime column to each with identical data but the (same?) dtype specified using different syntax. df["F_pd_DatetimeTZDtype"] = pd.array( ["2010/01/31 10:23:01", "1990", "2025/01/01 00:00+1", 1, "2024-12-31"], dtype=pd.DatetimeTZDtype(tz=ZoneInfo("Europe/Paris")), ) df2["F_pd_DatetimeTZDtype"] = pd.array( ["2010/01/31 10:23:01", "1990", "2025/01/01 00:00+1", 1, "2024-12-31"], dtype="datetime64[ns, Europe/Paris]", ) # Check if the dataframes are equal (this fails) pd.testing.assert_frame_equal(df, df2) ``` ### Issue Description As far as I'm aware, the `assert_frame_equal()` in the above example shouldn't fail but it thinks the dtypes are different: ```python-traceback AssertionError Traceback (most recent call last) Cell In[9], [line 1](vscode-notebook-cell:?execution_count=9&line=1) ----> [1](vscode-notebook-cell:?execution_count=9&line=1) pd.testing.assert_frame_equal(df, df2) [... skipping hidden 3 frame] File [~/miniconda3/envs/exio-datamanager/lib/python3.11/site-packages/pandas/_testing/asserters.py:614](https://file+.vscode-resource.vscode-cdn.net/home/peterma/exio_dev/repo/datamanager/scratch/~/miniconda3/envs/exio-datamanager/lib/python3.11/site-packages/pandas/_testing/asserters.py:614), in raise_assert_detail(obj, message, left, right, diff, first_diff, index_values) [611](https://file+.vscode-resource.vscode-cdn.net/home/peterma/exio_dev/repo/datamanager/scratch/~/miniconda3/envs/exio-datamanager/lib/python3.11/site-packages/pandas/_testing/asserters.py:611) if first_diff is not None: [612](https://file+.vscode-resource.vscode-cdn.net/home/peterma/exio_dev/repo/datamanager/scratch/~/miniconda3/envs/exio-datamanager/lib/python3.11/site-packages/pandas/_testing/asserters.py:612) msg += f"\n{first_diff}" --> [614](https://file+.vscode-resource.vscode-cdn.net/home/peterma/exio_dev/repo/datamanager/scratch/~/miniconda3/envs/exio-datamanager/lib/python3.11/site-packages/pandas/_testing/asserters.py:614) raise AssertionError(msg) AssertionError: Attributes of DataFrame.iloc[:, 3] (column name="F_pd_DatetimeTZDtype") are different Attribute "dtype" are different [left]: datetime64[ns, Europe/Paris] [right]: datetime64[ns, Europe/Paris] ``` Both an eyeball check and using `df.compare()` suggests the data itself is the same. Checking the dtype, and type of the dtype, looks the same too, e.g. ```python print(df["F_pd_DatetimeTZDtype"].dtype) print(type(df["F_pd_DatetimeTZDtype"].dtype)) print(df2["F_pd_DatetimeTZDtype"].dtype) print(type(df2["F_pd_DatetimeTZDtype"].dtype)) ``` produces ``` datetime64[ns, Europe/Paris] <class 'pandas.core.dtypes.dtypes.DatetimeTZDtype'> datetime64[ns, Europe/Paris] <class 'pandas.core.dtypes.dtypes.DatetimeTZDtype'> ``` However it fails with `assert_frame_equal()`. ### Expected Behavior That the dtype specified by the different syntax(es) `dtype=pd.DatetimeTZDtype(tz=ZoneInfo("Europe/Paris")` vs `dtype="datetime64[ns, Europe/Paris]"` shouldn't cause `assert_frame_equal()` to fail for the associated column. Unless I've badly misunderstood expected behaviour, which is quite possible. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.11.8.final.0 python-bits : 64 OS : Linux OS-release : 5.15.0-97-generic Version : #107~20.04.1-Ubuntu SMP Fri Feb 9 14:20:11 UTC 2024 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_GB.UTF-8 LOCALE : en_GB.UTF-8 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.1.0 pip : 24.0 Cython : None pytest : 8.0.0 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : 2023.10.1 fsspec : 2024.2.0 gcsfs : None matplotlib : None numba : None numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : 0.9.0 xarray : None xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2024.1 qtpy : None pyqt5 : None </details>
[ "Bug", "Testing", "Timezones" ]
0
0
0
0
0
0
0
0
[ "This is why it's raising.\r\n\r\n```\r\nprint(type(df[\"F_pd_DatetimeTZDtype\"].dtype.tz))\r\n# <class 'zoneinfo.ZoneInfo'>\r\n\r\nprint(type(df2[\"F_pd_DatetimeTZDtype\"].dtype.tz))\r\n# <class 'pytz.tzfile.Europe/Paris'>\r\n```\r\n\r\nNot sure if this is expected, cc @jbrockmendel \r\n", "i think its expected, but agreed it can be annoying. These dtypes are _mostly_ equivalent, but there are some corner cases where things can be different, so i think until @mroeschke's work converting the default to zoneinfo is done we need to just live with this", "@EsmeMaxwell - as mentioned above, this will be resolved by switching the default to zoneinfo. Closing." ]
2,156,450,794
57,643
BUG: interchange protocol with nullable datatypes a non-null validity provides nonsense results
closed
2024-02-27T12:21:12
2024-03-07T19:55:06
2024-03-07T19:55:06
https://github.com/pandas-dev/pandas/issues/57643
true
null
null
MarcoGorelli
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 pyarrow.interchange as pai import pandas as pd import polars as pl data = pd.DataFrame( { "b1": pd.Series([1, 2, None], dtype='Int64'), } ) print(pd.api.interchange.from_dataframe(data.__dataframe__())) print(pai.from_dataframe(data)) print(pl.from_dataframe(data)) ``` ### Issue Description Result: ``` b1 0 4607182418800017408 1 4611686018427387904 2 9221120237041090560 pyarrow.Table b1: int64 ---- b1: [[4607182418800017408,4611686018427387904,9221120237041090560]] shape: (3, 1) ┌─────────────────────┐ │ b1 │ │ --- │ │ i64 │ ╞═════════════════════╡ │ 4607182418800017408 │ │ 4611686018427387904 │ │ 9221120237041090560 │ └─────────────────────┘ ``` ### Expected Behavior `[1, 2, None]` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : 92a52e231534de236c4e878008a4365b4b1da291 python : 3.10.12.final.0 python-bits : 64 OS : Linux OS-release : 5.15.133.1-microsoft-standard-WSL2 Version : #1 SMP Thu Oct 5 21:02:42 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 3.0.0.dev0+355.g92a52e2315 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 59.6.0 pip : 24.0 Cython : 3.0.8 pytest : 8.0.0 hypothesis : 6.98.6 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.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.7 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.1.1 xlrd : 2.0.1 zstandard : 0.22.0 tzdata : 2024.1 qtpy : 2.4.1 pyqt5 : None </details>
[ "Bug", "Regression", "Interchange" ]
0
0
0
0
0
0
0
0
[ "this issue is here\r\n\r\nhttps://github.com/pandas-dev/pandas/blob/5f87a2dafcd5d05966e2f7cf9eab53dbba5abde1/pandas/core/interchange/column.py#L301\r\n\r\nThe other issue is\r\n\r\nhttps://github.com/pandas-dev/pandas/blob/5f87a2dafcd5d05966e2f7cf9eab53dbba5abde1/pandas/core/interchange/column.py#L191-L199", "same with `'Int64[pyarrow]'`" ]
2,156,298,628
57,642
QST: Grouping at fixed time intervals (hours and minutes) regardeless the date and the first row time
open
2024-02-27T11:02:00
2024-02-27T11:02:00
null
https://github.com/pandas-dev/pandas/issues/57642
true
null
null
fede72bari
0
### 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/questions/78062460/grouping-in-minutes-intervals-starting-at-fixed-time-regardless-the-first-row-ti ### Question about pandas I have this code intended to count occurrences in 30-minute intervals; the requirement is to have these intervals at fixed starting points, minute 00 and minute 30 of each hour. Regretfully, despite every attempt of mine, the second group is aligned to minute 03 and minute 33. I suspect that both the groups are aligned with the first time row and that the first one is correct just by chance. How can I tell the grouper to force the alignment to minutes 00 and 30? # load and prepare data df_long_forecast = pd.read_csv('df_long_forecast - reduced.csv') df_long_forecast['after_12_max_datetime'] = pd.to_datetime(df_long_forecast['after_12_max_datetime']) df_long_forecast['after_12_max_time'] = (df_long_forecast['after_12_max_datetime'] - df_long_forecast['after_12_max_datetime'].dt.normalize()) # timedelta64[ns] # count the number of maxes happening after 12am (absolute and percentage) hist_max = df_long_forecast.groupby(pd.Grouper(key='after_12_max_time', freq='30T', offset='0T', origin=origin))['Date'].count() percent_max = round(hist_max / hist_max.sum() * 100, 2) display(hist_max) # count the number of maxes after 12 that result in a profit trade (cannot be MORE than the previous ones) df_long_forecast_profit = df_long_forecast[ df_long_forecast['after_12_max_>_9_to_12_high'] > 0 ] profit_long = df_long_forecast_profit.groupby(pd.Grouper(key='after_12_max_time', freq='30T', offset='0T', origin=origin))['Date'].count() percent_profit_long = round(profit_long / hist_max.sum() * 100, 2) display(profit_long) Here is the print of the hist_max df ```none after_12_max_time 0 days 12:00:00 24 0 days 12:30:00 5 0 days 13:00:00 7 0 days 13:30:00 5 0 days 14:00:00 5 0 days 14:30:00 4 0 days 15:00:00 4 0 days 15:30:00 1 0 days 16:00:00 5 0 days 16:30:00 7 0 days 17:00:00 1 0 days 17:30:00 6 0 days 18:00:00 1 0 days 18:30:00 1 0 days 19:00:00 1 0 days 19:30:00 6 0 days 20:00:00 3 0 days 20:30:00 0 0 days 21:00:00 6 0 days 21:30:00 19 0 days 22:00:00 8 Freq: 30T, Name: Date, dtype: int64 ``` and this is profit_long ``` after_12_max_time 0 days 12:03:00 8 0 days 12:33:00 4 0 days 13:03:00 5 0 days 13:33:00 4 0 days 14:03:00 5 0 days 14:33:00 4 0 days 15:03:00 3 0 days 15:33:00 2 0 days 16:03:00 5 0 days 16:33:00 6 0 days 17:03:00 2 0 days 17:33:00 5 0 days 18:03:00 1 0 days 18:33:00 2 0 days 19:03:00 0 0 days 19:33:00 5 0 days 20:03:00 3 0 days 20:33:00 0 0 days 21:03:00 6 0 days 21:33:00 21 0 days 22:03:00 3 Freq: 30T, Name: Date, dtype: int64 ``` The CSV file with just the pertinent columns can be downloaded from this [link][1]. [1]: https://www.dropbox.com/scl/fi/mytcuez9yyb841vpj50vo/df_long_forecast-reduced.csv?rlkey=llnlvviird802ikxmkd3sjw15&dl=0
[ "Usage Question", "Needs Triage" ]
0
0
0
0
0
0
0
0
[]
2,156,040,638
57,641
Potential regression induced by PR #56921
open
2024-02-27T09:01:40
2024-03-04T04:10:33
null
https://github.com/pandas-dev/pandas/issues/57641
true
null
null
DeaMariaLeon
2
PR #56921 Benchmarks: `join_merge.Join.time_join_dataframes_cross` (Python) with sort=True `timeseries.ResetIndex.time_reset_datetimeindex` (Python) with t=None `timeseries.ResetIndex.time_reset_datetimeindex` (Python) with t='US/Eastern' `join_merge.Join.time_join_dataframes_cross` (Python) with sort=False @rhshadrach ![Screenshot 2024-02-27 at 09 58 18](https://github.com/pandas-dev/pandas/assets/11835246/d8600110-4318-4625-9e98-773cd8429539)
[ "Performance", "Regression", "Warnings" ]
0
0
0
0
0
0
0
0
[ "This is hitting the added check here:\r\n\r\nhttps://github.com/pandas-dev/pandas/blob/737d390381ffd8006f15d738c934acb659b5c444/pandas/core/internals/managers.py#L1531-L1534\r\n\r\nIt is hit twice for the entire benchmark; i.e. not in a tight loop. The regression is 0.2ms; this is expected. Closing.", "Reopening - this popped up on my regression tracker as well. However some of the times exceed 2ms, and should be investigated further.\r\n\r\n - [ ] [eval.Eval.time_chained_cmp](https://asv-runner.github.io/asv-collection/pandas/#eval.Eval.time_chained_cmp)\r\n - [ ] [engine='numexpr'; threads='all'](https://asv-runner.github.io/asv-collection/pandas/#eval.Eval.time_chained_cmp?p-engine=%27numexpr%27&p-threads=%27all%27)\r\n - [ ] [frame_methods.Shift.time_shift](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.Shift.time_shift)\r\n - [ ] [axis=1](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.Shift.time_shift?p-axis=1)\r\n - [ ] [indexing.InsertColumns.time_assign_list_like_with_setitem](https://asv-runner.github.io/asv-collection/pandas/#indexing.InsertColumns.time_assign_list_like_with_setitem)\r\n - [ ] [indexing.InsertColumns.time_assign_with_setitem](https://asv-runner.github.io/asv-collection/pandas/#indexing.InsertColumns.time_assign_with_setitem)\r\n - [ ] [indexing.InsertColumns.time_insert](https://asv-runner.github.io/asv-collection/pandas/#indexing.InsertColumns.time_insert)\r\n - [ ] [indexing.InsertColumns.time_insert_middle](https://asv-runner.github.io/asv-collection/pandas/#indexing.InsertColumns.time_insert_middle)\r\n - [ ] [reshape.SparseIndex.time_unstack](https://asv-runner.github.io/asv-collection/pandas/#reshape.SparseIndex.time_unstack)\r\n - [ ] [timeseries.ResetIndex.time_reset_datetimeindex](https://asv-runner.github.io/asv-collection/pandas/#timeseries.ResetIndex.time_reset_datetimeindex)\r\n - [ ] [t='US/Eastern'](https://asv-runner.github.io/asv-collection/pandas/#timeseries.ResetIndex.time_reset_datetimeindex?p-t=%27US/Eastern%27)\r\n - [ ] [t=None](https://asv-runner.github.io/asv-collection/pandas/#timeseries.ResetIndex.time_reset_datetimeindex?p-t=None)\r\n" ]
2,156,021,508
57,640
Potential regression induced by #57347
closed
2024-02-27T08:51:26
2024-02-27T10:02:14
2024-02-27T10:02:13
https://github.com/pandas-dev/pandas/issues/57640
true
null
null
DeaMariaLeon
1
PR #57347 May have induced a regression. Benchmark: `frame_methods.AsType.time_astype` (Python) with copy=False, from_to_dtypes=('float64[pyarrow]', 'float64[pyarrow]') @phofl <img width="1113" alt="Screenshot 2024-02-27 at 09 47 41" src="https://github.com/pandas-dev/pandas/assets/11835246/3081f142-7446-4537-99e9-d2736ca59379">
[]
0
0
0
0
0
0
0
0
[ "This is overhead that is generated by the warning that is raised now, so closing as expected. \r\n\r\nWe should get back to the original runtime by removing the copy keyword" ]
2,155,732,105
57,639
Create median_absolute_deviation
closed
2024-02-27T06:01:55
2024-02-27T15:28:39
2024-02-27T15:28:09
https://github.com/pandas-dev/pandas/pull/57639
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57639
https://github.com/pandas-dev/pandas/pull/57639
VasudevanS1906
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.
[ "Enhancement", "Needs Discussion" ]
0
0
0
0
0
0
0
0
[ "Thanks for the contribution @VasudevanS1906. I'm going to close this PR. You can surely open an issue to have a discussion on whether this is a function that we want to add to pandas or not.\r\n\r\nIn the case that people agree to add this, you'll have to implement this as all other methods, add tests, add documentation..." ]
2,155,621,322
57,638
DOC: RT03 fix for read_sql method
closed
2024-02-27T04:23:06
2024-02-27T17:03:12
2024-02-27T17:00:30
https://github.com/pandas-dev/pandas/pull/57638
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57638
https://github.com/pandas-dev/pandas/pull/57638
YashpalAhlawat
1
- [x] xref #57416 (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. - [ ] 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 SQL" ]
0
0
0
0
0
0
0
0
[ "Thanks @YashpalAhlawat " ]
2,155,546,852
57,637
BUG: Fix dataframe.update not updating dtype #55509 v2
closed
2024-02-27T02:56:34
2024-03-05T11:57:44
2024-03-02T18:57:28
https://github.com/pandas-dev/pandas/pull/57637
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57637
https://github.com/pandas-dev/pandas/pull/57637
aureliobarbosa
13
- [x] closes #55509. - [x] 3 Tests added and passed. - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [x] Added an entry in the latest `doc/source/whatsnew/v3.0.rst`. (?) A new PR was opened to replace the previous one (#55634) because a more idiomatic solution was found. The previous PR will be converted to draft. @rhshadrach @mroeschke
[ "Bug", "Dtype Conversions" ]
0
0
0
0
0
0
0
0
[ "Thanks for the contribution @aureliobarbosa. Can you add a note to the release notes please? You can check other PRs if you are not familiar with it.", "Sure. For which version? 3.0? @datapythonista ", "> Sure. For which version? 3.0? @datapythonista\r\n\r\nYes please", "Done @datapythonista", "Benchmarks from https://github.com/pandas-dev/pandas/pull/55634#discussion_r1375264127\r\n\r\n```\r\nsize = 100_000\r\ndf1 = pd.DataFrame({'a': np.random.randint(0, 100, size)}, index=range(1, size+1))\r\ndf2 = pd.DataFrame({'a': np.random.randint(0, 100, 3)}, index=[10, 12, 11])\r\n%timeit df1.update(df2)\r\n# 1.11 ms ± 10.1 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) <-- PR\r\n# 2.32 ms ± 36.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) <-- main\r\n\r\nsize = 100_000\r\nindex = list(range(1, size+1))\r\nindex[1], index[0] = index[0], index[1]\r\ndf1 = pd.DataFrame({'a': np.random.randint(0, 100, size)}, index=index)\r\ndf2 = pd.DataFrame({'a': np.random.randint(0, 100, 3)}, index=[10, 12, 11])\r\n%timeit df1.update(df2)\r\n# 1.05 ms ± 3.11 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) <-- PR\r\n# 1.76 ms ± 3.73 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) <-- main\r\n\r\nsize = 100_000\r\ndf1 = pd.DataFrame({'a': np.random.randint(0, 100, 3)}, index=[10, 11, 12])\r\ndf2 = pd.DataFrame({'a': np.random.randint(0, 100, size)})\r\n%timeit df1.update(df2)\r\n# 517 µs ± 1.54 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) <-- PR\r\n# 318 µs ± 4.85 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) <-- main\r\n\r\nsize = 10\r\ndf1 = pd.DataFrame({'a': np.random.randint(0, 100, size)})\r\ndf2 = pd.DataFrame({'a': [-1, -2, -3]}, index=[4, 4, 6])\r\ndf1.update(df2)\r\n# ValueError: Update not allowed with duplicate indexes on other. <-- PR\r\n# ValueError: cannot reindex on an axis with duplicate labels <-- main\r\n```", "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57637/", "@datapythonista I am looking into ASV right now. Which kind of benchmark would be more useful: time, memory or both? Can you point me to a properly designed pandas benchmark so that I can have a reference for an start on this?\n\nIndependent of this, manual tests are going to be done locally and posted here for reference, in the following.", "I think all our benchmarks should be reasonable. Understanding and running asv may be a bit tricky, but writing the benchmark should be trivial, just create some sample data and call `DataFrame.update` with it. I think checking time is probably good enough. The main complexity in my opinion is to use enough data so the timing is not super noise, but not have too much so the benchmark is slow.\r\n\r\nAlso, we use benchmarks more for the algorithms that we implement ourselves (like in C) that to check the performance of everything. I think in this case it can be useful, but use your own judgement to decide whether it's useful or not.", "@datapythonista \r\n\r\n> Do you think it's worth adding a use case to test when the indices have no intersection?\r\n\r\nI agree because this is a behavior that was introduced on this PR. Added the test for this case and changed the message raise slightly to emphasize 'no intersection'.\r\n\r\n> not sure if we can find a better name for the variable rows. Maybe mask or index_intersection is better.\r\n\r\nThe first of this PR used `indexes_intersection`, but then I changed to `rows` to simplify the notation. Now that you raised this point, I noted that a simple search on the file `frame.py` results in more than one hundred matches. Considering this, I agree with avoided using `rows`.", "I did benchmark again the first three manual code tests proposed previously by @rhshadrach. Results are summarized below in the same order.\r\n\r\n| Data | main | PR | \r\n| --- | --- | --- |\r\n| monotonic | 1.8 ms | 1.29 ms | \r\n| non-monotonic | 1.83 ms | 1.21 ms | \r\n| small-frame-large-arg | 384 µs |595 µs | \r\n\r\nThe performance gain is not as good as originally expected, but they are still relevant (28%~34% on large frames with small arguments!). @datapythonista Note that when the frame is small and the argument is large there is a performance loss, but as pointed out previously by @rhshadrach this looks like an edge use case.", "Hope to be done here. \r\n\r\n@datapythonista Next thing I will do is to try to implement an ASV benchmark for this function.\r\n\r\n@rhshadrach I think that the take home message on this PR was that the function was manipulating data it wasn't expecting to touch on, and this case, the change in the dtype was the symptom for this problem. \r\n\r\nIf you both know or find any bug that could be related or similar to this one, I would be glad to contribute.\r\n\r\nRegards", "Thanks @aureliobarbosa!" ]
2,155,319,304
57,636
BUG: .str.replace repl string incorrectly parsed with pyarrow string dtype
open
2024-02-26T22:58:33
2025-07-15T20:44:18
null
https://github.com/pandas-dev/pandas/issues/57636
true
null
null
jamesmyatt
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 pandas as pd # Enable pandas 3.0 options pd.options.mode.copy_on_write = True pd.options.future.infer_string = True pat = r"(?P<one>\w+) (?P<two>\w+) (?P<three>\w+)" ser = pd.Series(['One Two Three', 'Foo Bar Baz']) repl = r"\g<three> \g<two> \g<one>" ser.str.replace(pat, repl, regex=True) repl = r"\g<2>0" # Note that this should be different from r"\20" according to the `re.sub` docs. ser.str.replace(pat, repl, regex=True) repl = r"\20" # Should throw error since group 20 doesn't exist according to the `re.sub` docs. ser.str.replace(pat, repl, regex=True) ``` ### Issue Description The docs for [`.str.replace`](https://pandas.pydata.org/docs/reference/api/pandas.Series.str.replace.html) imply that the repl string can be anything that [`re.sub`](https://docs.python.org/3/library/re.html#re.sub) supports when `regex=True`. I think this is true for the current functionality, but isn't when using the pyarrow string dtype (`pd.options.future.infer_string = True`). Specifically, the first 2 cases above throw the following error, but should work: ``` ArrowInvalid: Invalid replacement string: Rewrite schema error: '\' must be followed by a digit or '\'. ``` The last case above should throw, but instead is incorrectly treated as `\g<2>0`. I guess that this is really an issue in the PyArrow backend rather than in pandas itself. ### Expected Behavior Matches `pd.options.future.infer_string = False` and matches `re.sub`. ### Installed Versions <details> ``` INSTALLED VERSIONS ------------------ commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.11.7.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22621 machine : AMD64 processor : Intel64 Family 6 Model 154 Stepping 4, GenuineIntel byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : English_United Kingdom.1252 pandas : 2.2.0 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : 24.0 Cython : None pytest : 8.0.0 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.7 dataframe-api-compat : None fastparquet : None fsspec : 2024.2.0 gcsfs : None matplotlib : 3.8.2 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : None pandas_gbq : None pyarrow : 15.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.12.0 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None ``` </details>
[ "Bug", "Strings", "Arrow" ]
0
0
0
0
0
0
0
0
[ "Full trace for first case:\r\n\r\n<details>\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nArrowInvalid Traceback (most recent call last)\r\nCell In[47], line 6\r\n 3 ser = pd.Series(['One Two Three', 'Foo Bar Baz'])\r\n 5 repl = r\"\\g<three> \\g<two> \\g<one>\"\r\n----> 6 ser.str.replace(pat, repl, regex=True)\r\n 8 repl = r\"\\g<2>0\" # Note that this is different from r\"\\20\".\r\n 9 ser.str.replace(pat, repl, regex=True)\r\n\r\nFile ...\\Lib\\site-packages\\pandas\\core\\strings\\accessor.py:137, in forbid_nonstring_types.<locals>._forbid_nonstring_types.<locals>.wrapper(self, *args, **kwargs)\r\n 132 msg = (\r\n 133 f\"Cannot use .str.{func_name} with values of \"\r\n 134 f\"inferred dtype '{self._inferred_dtype}'.\"\r\n 135 )\r\n 136 raise TypeError(msg)\r\n--> 137 return func(self, *args, **kwargs)\r\n\r\nFile ...\\Lib\\site-packages\\pandas\\core\\strings\\accessor.py:1567, in StringMethods.replace(self, pat, repl, n, case, flags, regex)\r\n 1564 if case is None:\r\n 1565 case = True\r\n-> 1567 result = self._data.array._str_replace(\r\n 1568 pat, repl, n=n, case=case, flags=flags, regex=regex\r\n 1569 )\r\n 1570 return self._wrap_result(result)\r\n\r\nFile ...\\Lib\\site-packages\\pandas\\core\\arrays\\string_arrow.py:417, in ArrowStringArray._str_replace(self, pat, repl, n, case, flags, regex)\r\n 414 return super()._str_replace(pat, repl, n, case, flags, regex)\r\n 416 func = pc.replace_substring_regex if regex else pc.replace_substring\r\n--> 417 result = func(self._pa_array, pattern=pat, replacement=repl, max_replacements=n)\r\n 418 return type(self)(result)\r\n\r\nFile ...\\Lib\\site-packages\\pyarrow\\compute.py:263, in _make_generic_wrapper.<locals>.wrapper(memory_pool, options, *args, **kwargs)\r\n 261 if args and isinstance(args[0], Expression):\r\n 262 return Expression._call(func_name, list(args), options)\r\n--> 263 return func.call(args, options, memory_pool)\r\n\r\nFile ...\\Lib\\site-packages\\pyarrow\\_compute.pyx:385, in pyarrow._compute.Function.call()\r\n\r\nFile ...\\Lib\\site-packages\\pyarrow\\error.pxi:154, in pyarrow.lib.pyarrow_internal_check_status()\r\n\r\nFile ...\\Lib\\site-packages\\pyarrow\\error.pxi:91, in pyarrow.lib.check_status()\r\n\r\nArrowInvalid: Invalid replacement string: Rewrite schema error: '\\' must be followed by a digit or '\\'.\r\n```\r\n\r\n</details>", "__Update__: I've updated the issue to reflect the fact that I think there are wider issues with the repl string parsing than just named groups." ]
2,155,274,217
57,635
BUG: Ensure dataframe preserves categorical indices with categorial series
closed
2024-02-26T22:23:09
2024-06-01T11:49:51
2024-05-31T18:53:20
https://github.com/pandas-dev/pandas/pull/57635
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57635
https://github.com/pandas-dev/pandas/pull/57635
jmarintur
3
Ensure that when constructing a DataFrame with a list of Series with different CategoricalIndexes, the resulting columns are categorical. - [x] closes #57592 - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
[ "Categorical", "DataFrame", "Constructors" ]
0
0
0
0
0
0
0
0
[ "Hi @mroeschke, Unit Tests failures seem unrelated (when running them locally everything is ok).", "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.", "Dear @mroeschke, could you please give me some feedback? I'd like to understand what's missing in my last changes. " ]
2,155,051,468
57,634
Support structural subtyping with ExtensionArray
closed
2024-02-26T20:21:56
2024-03-19T20:04:51
2024-03-19T20:04:51
https://github.com/pandas-dev/pandas/pull/57634
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57634
https://github.com/pandas-dev/pandas/pull/57634
WillAyd
7
- [X] closes #57633 This is a very naive implementation. Ideally we would move a lot of the extraneous functions / attributes out of the core `ExtensionArray` class and into a better home
[ "ExtensionArray" ]
0
0
0
0
0
0
0
0
[ "> move a lot of the extraneous functions / attributes out of the core ExtensionArray class and into a better home\r\n\r\nCan you expand on this? Early on when implementing EAs there was an idea that it could be implemented in terms of a small number of primitives (so the EA namespace could stay small) but that idea didn't pan out.", "Yea I am referring to anything that is a method on the ExtensionArray but that is not documented as part of the interface. `_values_for_json`, `_get_repr_footer`, etc... work when you use structural typing instead of nominal typing you'd have to re-implement those (see the test case)", "So is the suggestion to move those things out of the EA namespace or just to document them as required?\r\n\r\nThis Protocol approach seems to make it difficult to implement default-but-overridable implementations for things.", "Yea not sure yet how to best move things. Maybe that would require something like `ExtensionArrayDefaultOpsMixin`? ", "> Yea not sure yet how to best move things. Maybe that would require something like ExtensionArrayDefaultOpsMixin?\r\n\r\nThis seems like a lot of effort to reinvent the idea of a subclass. Is there any evidence that this is a pain point for 3rd parties?\r\n", "I am not aware of an existing library asking for this. It would be a new feature for a library that in the future may want to implement a class in an extension without having to interact heavily with the Python runtime", "Closing for now - may revisit later" ]
2,154,995,455
57,633
ENH: Make ExtensionArray a Protocol
open
2024-02-26T19:47:33
2025-06-29T16:58:59
null
https://github.com/pandas-dev/pandas/issues/57633
true
null
null
WillAyd
7
### Feature Type - [X] Adding new functionality to pandas - [ ] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description The current pandas ExtensionArray is a standard Python class, and throughout our code base we do things like `isinstance(obj, ExtensionArray)` to determine at runtime if an object is an instance of the ExtensionArray. While this works for classes implemented purely in Python that may inherit from a Python class, it does not work with extension classes that are implemented in either Cython, pybind11, nanobind, etc... See https://cython.readthedocs.io/en/latest/src/userguide/extension_types.html#subclassing for documentation of this limitation in Cython As such, unless you implement your extension purely in Python it will not work correctly as an ExtensionArray ### Feature Description PEP 544 describes the [runtime_checkable](https://peps.python.org/pep-0544/#runtime-checkable-decorator-and-narrowing-types-by-isinstance) decorator that in theory can solve this issue without any major changes to our code base (ignoring any performance implications for now) ### Alternative Solutions Not sure there are any - I may be wrong but I do not think extension types in Python can inherit from Python types ### Additional Context _No response_
[ "Enhancement", "ExtensionArray", "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "> Not sure there are any - I may be wrong but I do not think extension types in Python can inherit from Python types\r\n\r\nCan't you\r\n\r\n```\r\ncdef class ActualImplementation:\r\n [most of the implementation]\r\n\r\nclass MyEA(ActualImplementation, ExtensionArray):\r\n pass\r\n```\r\n\r\nThat's basically what we do with `NDArrayBacked`.", "That works until you try to call an method of the extension class. `MyEA().copy()` will return an instance of `ActualImplementation` not of `MyEA`", "Ah I take that back - OK cool I'll have to look more into what Cython is doing to make that maintain the MyEA type. Was not getting this with nanobind so must be a Cython feature:\r\n\r\n```\r\nimport numpy as np\r\n\r\nfrom pandas.api.extensions import ExtensionArray\r\nfrom pandas._libs.arrays import NDArrayBacked\r\n\r\n\r\nclass MyEA(NDArrayBacked, ExtensionArray):\r\n ...\r\n\r\narr = MyEA(np.arange(3), np.int64)\r\nassert type(arr) == type(arr.copy())\r\n```", "Yah I’m implicitly assuming the implementation returns type(self) instead\r\nof hard-coding the class there. That seems pretty harmless to me.\r\n\r\nOn Mon, Feb 26, 2024 at 1:20 PM William Ayd ***@***.***>\r\nwrote:\r\n\r\n> That works until you try to call an method of the extension class.\r\n> MyEA().copy() will return an instance of ActualImplementation not of MyEA\r\n>\r\n> —\r\n> Reply to this email directly, view it on GitHub\r\n> <https://github.com/pandas-dev/pandas/issues/57633#issuecomment-1965310556>,\r\n> or unsubscribe\r\n> <https://github.com/notifications/unsubscribe-auth/AB5UM6CFMVNUFOA6VFEDQF3YVT4BNAVCNFSM6AAAAABD2Z4EU2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRVGMYTANJVGY>\r\n> .\r\n> You are receiving this because you commented.Message ID:\r\n> ***@***.***>\r\n>\r\n", "> PEP 544 describes the [runtime_checkable](https://peps.python.org/pep-0544/#runtime-checkable-decorator-and-narrowing-types-by-isinstance) decorator that in theory can solve this issue without any major changes to our code base (ignoring any performance implications for now)\r\n\r\nI think `isinstance` checks on a protocol are more expensive than on concrete classes: comparing all symbols (protocol) vs just checking `__mro__` (concrete class)", "Yea there is going to be some performance overhead, I think especially before Python 3.12. How much that matters I don't know - I am under the impression we aren't doing these checks in a tight loop but if you have ideas on what to benchmark happy to profile", "We aren’t doing the checks in a tight loop, but we are doing them _everywhere_." ]
2,154,817,054
57,632
Compile take functions for uint dtypes
closed
2024-02-26T18:18:13
2024-03-16T23:38:34
2024-03-16T17:47:44
https://github.com/pandas-dev/pandas/pull/57632
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57632
https://github.com/pandas-dev/pandas/pull/57632
phofl
6
Not sure why this wasn't compiled before, maybe because of wheel size? We should at least compile the exact matching, not averse to skipping the cross product with different itemsizes
[ "Internals" ]
0
0
0
0
0
0
0
0
[ "Seems fine. Are these actually called?", "Those are more or less user facing, we end up calling them if users have uint dtypes (that's how we found this in Dask)\r\n\r\ngood to merge @WillAyd?", "Yep merge away", "thx", "For all dtypes of the same itemsize, is it possible to e.g. view them as an int8/16/32/64, and just have one kernel that does int->int take, or is this undefined behavior?", "Would still require a copy and this is a path that is very heavily used." ]
2,154,622,902
57,631
pandas 2.2.1 introduce API changes, for example for `groupby().first`, `groupby().last` and `series.argsort`
closed
2024-02-26T16:40:38
2024-02-27T16:53:08
2024-02-27T16:53:08
https://github.com/pandas-dev/pandas/issues/57631
true
null
null
anmyachev
9
This makes code written in Pandas 2.2.1 incompatible with 2.2.0. Was this done by mistake or on purpose? As far as I know, Pandas follows the semver methodology and this change is unexpected for me.
[ "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "Not sure about the `argsort` change. Would be great to see an example of the change.\r\n\r\nThe other change is expected as noted in https://pandas.pydata.org/docs/whatsnew/v2.2.1.html#other and detailed in https://github.com/pandas-dev/pandas/pull/57102 cc @rhshadrach ", "> Not sure about the argsort change. Would be great to see an example of the change.\r\n\r\nIn pandas 2.2.1 (in comparison with 2.2.0) https://pandas.pydata.org/docs/reference/api/pandas.Series.argsort.html#pandas.Series.argsort has a new `stable` parameter.", "I see thanks for point that out.\r\n\r\nThis PR introduced that change and was meant to give pandas 2.2.x potential compatibility with Numpy 2.0 when it comes out: https://github.com/pandas-dev/pandas/pull/57057. Sorry for not documenting it in the what's new, but the new argument was made backward compatible and doesn't change the behavior of `argsort`\r\n\r\n", "@mroeschke just to be sure, pandas patch releases only guarantee backward compatibility and not forward compatibility?", "I'm a little confused what forward compatible means in this context, but these changes will also apply to the next minor/major release (3.0)", "I mean a situation where, for example, the code is written with the new parameters existing for version 2.2.1, but the user encountered some kind of error and decided to run the same code on pandas 2.2.0 (where parameters may not yet exist). Can one expect the code to work?", "> As far as I know, Pandas follows the semver methodology and this change is unexpected for me.\r\n\r\n[pandas uses a loose variant of semantic versioning SemVer to govern deprecations, API compatibility, and version numbering.](https://pandas.pydata.org/docs/dev/development/policies.html#version-policy)\r\n\r\nIn the case of groupby first/last, the decision to add in 2.2.1 was made because we accidentally removed the ability of users to achieve the result with `skipna=False` in 2.0, and this was only brought to our attention as part of the 2.2.x development.", "> the code is written with the new parameters existing for version 2.2.1, but the user encountered some kind of error and decided to run the same code on pandas 2.2.0 (where parameters may not yet exist). Can one expect the code to work?\r\n\r\nFor this example, no `argsort` with `stable` usage written in 2.2.1 will not be expected to work in 2.2.0", "@mroeschke @rhshadrach thanks for the clarification! I received answers to all the questions, I think the issue can be closed." ]
2,154,425,248
57,630
DOC: fix PR01/SA01 errors for pandas.tseries.offsets.*.is_(month|quarter|year)_(end|start)
closed
2024-02-26T15:14:39
2024-02-28T04:34:41
2024-02-27T16:54:13
https://github.com/pandas-dev/pandas/pull/57630
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57630
https://github.com/pandas-dev/pandas/pull/57630
yuanx749
5
- [x] xref #57438 (Replace xxxx with the GitHub issue number) - [x] xref #57417 (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", "Datetime" ]
0
0
0
0
0
0
0
0
[ "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57630/", "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57630/", "Thanks @yuanx749 " ]
2,154,201,318
57,629
second approach to fix setitem parametrizations
closed
2024-02-26T13:35:00
2024-05-15T17:53:29
2024-05-15T17:53:29
https://github.com/pandas-dev/pandas/pull/57629
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57629
https://github.com/pandas-dev/pandas/pull/57629
lopof
2
- [x] closes #56727 - [ ] All [code checks passed] Unfortunately not, maybe related to #56329 - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "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.", "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,153,017,430
57,628
BUG: Unexpected behaviour when inserting timestamps into Series #57596
closed
2024-02-26T00:25:00
2024-02-27T14:41:58
2024-02-27T14:41:58
https://github.com/pandas-dev/pandas/pull/57628
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57628
https://github.com/pandas-dev/pandas/pull/57628
wleong1
1
Resolution info: **Resolution.RESO_SEC - 3 for seconds** **Resolution.RESO_MIN - 4 for minute** Observation: With the previous code, when the current entry (**resolution: 4, entry: '2024-02-24 10:08'**) has a greater resolution value than the smallest amongst previous entries (in this case **resolution: 3, entry: '2024-02-24 10:2:30'**), it is shown that the key is said to exist within the list of keys within the Series even though it shouldn't. This does not happen when a smaller or equal resolution value entry is inserted into the Series. ![Screenshot from 2024-02-26 13-14-10](https://github.com/pandas-dev/pandas/assets/122815453/0ec3fc4d-4831-47ac-9c19-c8b8fdbbaea9) Thought process: With the previous code, if the current entry's resolution value is greater than the smallest resolution value amongst the previous entries, the *_LocIndexer._convert_to_indexer* method will only return an empty list (output of the method *labels.get_loc(key)*), which might be causing entries with larger resolution values not being inserted into the *Series* correctly. Potential solution: I have changed the method *_LocIndexer._convert_to_indexer* to return the key ('2024-02-24 10:08') instead of an empty list when the resolution value is greater than the smallest resolution value. - [x] closes #57596 - [ ] [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/v2.2.1.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[ "Thanks for the contribution @wleong1. Seems like something is wrong with this PR. I think you may want to clone pandas again, and before implementing your changes create a branch in git. If you work in the main branch, things get mixed with other changes, as I think it's the case here.\r\n\r\nI'll close this, since you'll have to create a new PR if you work work in a different branch. Please let us know if you need help. " ]
2,152,979,508
57,627
DEPR: remove deprecated units ‘H’, ’T’, and smaller from Timedelta, TimedeltaIndex
closed
2024-02-25T22:55:17
2024-03-21T21:02:04
2024-03-21T19:17:20
https://github.com/pandas-dev/pandas/pull/57627
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57627
https://github.com/pandas-dev/pandas/pull/57627
natmokval
0
xref #54061 removed deprecated units `"H", "T", "S", "t", "L", "l", "U", "u", "N", "n"` from Timedelta, TimedeltaIndex UPDATE: - Enforced deprecation of strings ``T, t``, ``L, l``, ``U, u``, and ``N, n`` denoting frequencies in classes`Minute`, `Milli` `Micro`, and `Nano` - Enforced deprecation of strings ``T, t``, ``L, l``, ``U, u``, and ``N, n`` denoting units in class `Timedelta`
[ "Timedelta", "Deprecate" ]
0
0
0
0
0
0
0
0
[]
2,152,966,230
57,626
BUG: Unexpected behaviour when inserting timestamps into Series (#57596)
closed
2024-02-25T22:17:11
2024-02-26T00:08:30
2024-02-26T00:08:30
https://github.com/pandas-dev/pandas/pull/57626
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57626
https://github.com/pandas-dev/pandas/pull/57626
wleong1
0
…Series #57596 - [x] closes #57596 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [x] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [x] Added an entry in the latest `doc/source/whatsnew/v2.2.1.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[]
2,152,961,295
57,625
remove check to enforce ES01 errors
closed
2024-02-25T22:04:10
2024-02-26T18:19:29
2024-02-26T17:56:33
https://github.com/pandas-dev/pandas/pull/57625
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57625
https://github.com/pandas-dev/pandas/pull/57625
jordan-d-murphy
1
- [x] closes https://github.com/pandas-dev/pandas/issues/57440 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Code Style" ]
0
0
0
0
0
0
0
0
[ "Thanks @jordan-d-murphy " ]
2,152,897,375
57,624
Potential regression induced by PR #57534
closed
2024-02-25T19:03:33
2024-02-26T17:55:26
2024-02-26T17:55:25
https://github.com/pandas-dev/pandas/issues/57624
true
null
null
rhshadrach
1
PR #57534 may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. - [ ] [groupby.Apply.time_scalar_function_single_col](https://asv-runner.github.io/asv-collection/pandas/#groupby.Apply.time_scalar_function_single_col) - [ ] [factor=5](https://asv-runner.github.io/asv-collection/pandas/#groupby.Apply.time_scalar_function_single_col?p-factor=5) - [ ] [indexing.ChainIndexing.time_chained_indexing](https://asv-runner.github.io/asv-collection/pandas/#indexing.ChainIndexing.time_chained_indexing) - [ ] [mode='warn'](https://asv-runner.github.io/asv-collection/pandas/#indexing.ChainIndexing.time_chained_indexing?p-mode=%27warn%27) - [ ] [mode=None](https://asv-runner.github.io/asv-collection/pandas/#indexing.ChainIndexing.time_chained_indexing?p-mode=None) - [ ] [indexing.NumericSeriesIndexing.time_getitem_array](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_getitem_array) - [ ] [dtype=<class 'numpy.int64'>; index_structure='unique_monotonic_inc'](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_getitem_array?p-dtype=%3Cclass%20%27numpy.int64%27%3E&p-index_structure=%27unique_monotonic_inc%27) - [ ] [indexing.NumericSeriesIndexing.time_iloc_array](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_iloc_array) - [ ] [dtype=<class 'numpy.int64'>; index_structure='unique_monotonic_inc'](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_iloc_array?p-dtype=%3Cclass%20%27numpy.int64%27%3E&p-index_structure=%27unique_monotonic_inc%27) - [ ] [indexing.NumericSeriesIndexing.time_loc_array](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_loc_array) - [ ] [dtype=<class 'numpy.int64'>; index_structure='unique_monotonic_inc'](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_loc_array?p-dtype=%3Cclass%20%27numpy.int64%27%3E&p-index_structure=%27unique_monotonic_inc%27) - [ ] [timedelta.TimedeltaIndexing.time_union](https://asv-runner.github.io/asv-collection/pandas/#timedelta.TimedeltaIndexing.time_union) Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. [Commit Range](https://github.com/pandas-dev/pandas/compare/1625d5a9112a0143c1dc59eadab825536e7e1240...2b82b8635d17c3a020e6e40ba72b9cc6a76f3149) cc @mroeschke
[ "Performance", "Regression", "Index" ]
0
0
0
0
0
0
0
0
[ "Since this is closely related to https://github.com/pandas-dev/pandas/issues/57622, going to close for the same reason" ]
2,152,896,189
57,623
Potential regression induced by PR #57479
closed
2024-02-25T19:00:18
2024-02-25T21:45:07
2024-02-25T21:45:07
https://github.com/pandas-dev/pandas/issues/57623
true
null
null
rhshadrach
4
PR #57479 may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. - [ ] [frame_methods.Fillna.time_fillna](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.Fillna.time_fillna) - [ ] [inplace=True; dtype='float32'](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.Fillna.time_fillna?p-inplace=True&p-dtype=%27float32%27) - [ ] [inplace=True; dtype='float64'](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.Fillna.time_fillna?p-inplace=True&p-dtype=%27float64%27) Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. [Commit Range](https://github.com/pandas-dev/pandas/compare/260a703f8b69d04b4a84277a44d67d4feb3f8e8b...1625d5a9112a0143c1dc59eadab825536e7e1240) cc @phofl
[ "Missing-data", "Performance", "Regression" ]
0
0
0
0
0
0
0
0
[ "Not certain this is the PR that introduced the regression. Is it possible that making the shallow copy improves performance?", "@phofl This is the commit I mentioned to you on Slack (the one you thought that was off).", "> Not certain this is the PR that introduced the regression. Is it possible that making the shallow copy improves performance?\r\n\r\nYep possible, the shallow copy sets up references which means that follow up operations are not inplace anymore, which is sometimes faster. I would close here since this preserves the semantics that we want", "Thanks for checking." ]
2,152,893,987
57,622
Potential regression induced by PR #57445
closed
2024-02-25T18:54:20
2024-02-25T21:47:21
2024-02-25T21:47:07
https://github.com/pandas-dev/pandas/issues/57622
true
null
null
rhshadrach
4
PR #57445 may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. - [ ] [frame_methods.SortValues.time_frame_sort_values](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.SortValues.time_frame_sort_values) - [x] [ascending=False](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.SortValues.time_frame_sort_values?p-ascending=False) - [x] [ascending=True](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.SortValues.time_frame_sort_values?p-ascending=True) - [ ] [gil.ParallelGroups.time_get_groups](https://asv-runner.github.io/asv-collection/pandas/#gil.ParallelGroups.time_get_groups) - [x] [threads=2](https://asv-runner.github.io/asv-collection/pandas/#gil.ParallelGroups.time_get_groups?p-threads=2) - [x] [threads=4](https://asv-runner.github.io/asv-collection/pandas/#gil.ParallelGroups.time_get_groups?p-threads=4) - [x] [threads=8](https://asv-runner.github.io/asv-collection/pandas/#gil.ParallelGroups.time_get_groups?p-threads=8) - [ ] [groupby.Groups.time_series_groups](https://asv-runner.github.io/asv-collection/pandas/#groupby.Groups.time_series_groups) - [ ] [key='int64_large'](https://asv-runner.github.io/asv-collection/pandas/#groupby.Groups.time_series_groups?p-key=%27int64_large%27) - [ ] [key='int64_small'](https://asv-runner.github.io/asv-collection/pandas/#groupby.Groups.time_series_groups?p-key=%27int64_small%27) - [ ] [key='object_large'](https://asv-runner.github.io/asv-collection/pandas/#groupby.Groups.time_series_groups?p-key=%27object_large%27) - [ ] [key='object_small'](https://asv-runner.github.io/asv-collection/pandas/#groupby.Groups.time_series_groups?p-key=%27object_small%27) - [ ] [indexing.ChainIndexing.time_chained_indexing](https://asv-runner.github.io/asv-collection/pandas/#indexing.ChainIndexing.time_chained_indexing) - [ ] [mode='warn'](https://asv-runner.github.io/asv-collection/pandas/#indexing.ChainIndexing.time_chained_indexing?p-mode=%27warn%27) - [ ] [mode=None](https://asv-runner.github.io/asv-collection/pandas/#indexing.ChainIndexing.time_chained_indexing?p-mode=None) - [ ] [indexing.NumericSeriesIndexing.time_getitem_array](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_getitem_array) - [ ] [dtype=<class 'numpy.int64'>; index_structure='unique_monotonic_inc'](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_getitem_array?p-dtype=%3Cclass%20%27numpy.int64%27%3E&p-index_structure=%27unique_monotonic_inc%27) - [ ] [indexing.NumericSeriesIndexing.time_iloc_array](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_iloc_array) - [ ] [dtype=<class 'numpy.int64'>; index_structure='unique_monotonic_inc'](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_iloc_array?p-dtype=%3Cclass%20%27numpy.int64%27%3E&p-index_structure=%27unique_monotonic_inc%27) - [ ] [indexing.NumericSeriesIndexing.time_loc_array](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_loc_array) - [ ] [dtype=<class 'numpy.int64'>; index_structure='unique_monotonic_inc'](https://asv-runner.github.io/asv-collection/pandas/#indexing.NumericSeriesIndexing.time_loc_array?p-dtype=%3Cclass%20%27numpy.int64%27%3E&p-index_structure=%27unique_monotonic_inc%27) - [ ] [reshape.ReshapeMaskedArrayDtype.time_stack](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeMaskedArrayDtype.time_stack) - [ ] [dtype='Float64'](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeMaskedArrayDtype.time_stack?p-dtype=%27Float64%27) - [ ] [dtype='Int64'](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeMaskedArrayDtype.time_stack?p-dtype=%27Int64%27) Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. [Commit Range](https://github.com/pandas-dev/pandas/compare/abc3efb63f02814047a1b291ac2b1ee3cd70252f...1e9ccccb068f3c75058e8280570a8def3141a1c3) cc @mroeschke
[ "Performance", "Regression", "Index" ]
0
0
0
0
0
0
0
0
[ "@mroeschke - I've checked off the regressions where there are already fixes in place.", "Thanks!", "I think these are also mostly expected. There's a tradeoff here of doing More Work to potentially save memory in the resulting object.\r\n\r\nAlso in terms of milestoning this issue (and others), if the original PR was targeted for 3.0 shouldn't this issue milestone also be 3.0?", "Makes sense on both counts, should have been milestoned as 3.0." ]
2,152,893,193
57,621
Potential regression induced by PR #57402
closed
2024-02-25T18:52:11
2024-02-25T21:48:00
2024-02-25T21:47:59
https://github.com/pandas-dev/pandas/issues/57621
true
null
null
rhshadrach
1
PR #57402 may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. - [ ] [indexing.Block.time_test](https://asv-runner.github.io/asv-collection/pandas/#indexing.Block.time_test) - [ ] [param1='True'; param2='np.array(True)'](https://asv-runner.github.io/asv-collection/pandas/#indexing.Block.time_test?p-param1=%27True%27&p-param2=%27np.array%28True%29%27) - [ ] [param1='True'; param2=array(True)](https://asv-runner.github.io/asv-collection/pandas/#indexing.Block.time_test?p-param1=%27True%27&p-param2=array%28True%29) Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. [Commit Range](https://github.com/pandas-dev/pandas/compare/7e255a65ba837ef646d87655b4de3518a173b459...aa6ab37499268e01e21610e6bb201c9659c02fb3) cc @MarcoGorelli
[ "Indexing", "Performance", "Regression" ]
0
0
0
0
0
0
0
0
[ "thanks for the ping - tbh I think this expected, we do a bit more work upfront but end up with a column of an appropriate dtype" ]
2,152,890,684
57,620
Potential regression induced by PR #57302
closed
2024-02-25T18:45:30
2025-04-13T17:22:55
2025-04-13T17:22:53
https://github.com/pandas-dev/pandas/issues/57620
true
null
null
rhshadrach
1
PR #57302 may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. - [reshape.ReshapeExtensionDtype.time_stack](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeExtensionDtype.time_stack) - [dtype='Period[s]'](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeExtensionDtype.time_stack?p-dtype=%27Period%5Bs%5D%27) - [dtype='datetime64[ns, US/Pacific]'](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeExtensionDtype.time_stack?p-dtype=%27datetime64%5Bns%2C%20US/Pacific%5D%27) - [reshape.ReshapeMaskedArrayDtype.time_stack](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeMaskedArrayDtype.time_stack) - [dtype='Float64'](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeMaskedArrayDtype.time_stack?p-dtype=%27Float64%27) - [dtype='Int64'](https://asv-runner.github.io/asv-collection/pandas/#reshape.ReshapeMaskedArrayDtype.time_stack?p-dtype=%27Int64%27) - [reshape.SimpleReshape.time_stack](https://asv-runner.github.io/asv-collection/pandas/#reshape.SimpleReshape.time_stack) Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. [Commit Range](https://github.com/pandas-dev/pandas/compare/99a30a6d0b2765d5769b18a9d0da11f149bb7366...44c50b20e8d08613144b3353d9cd0844a53bd077) cc @rhshadrach
[ "Performance", "Reshaping", "Regression" ]
0
0
0
0
0
0
0
0
[ "Closed by https://github.com/pandas-dev/pandas/pull/58027" ]
2,152,889,030
57,619
Potential regression induced by PR #57328
closed
2024-02-25T18:40:46
2024-02-26T02:42:57
2024-02-26T02:42:57
https://github.com/pandas-dev/pandas/issues/57619
true
null
null
rhshadrach
3
PR #57328 may have induced a performance regression. If it was a necessary behavior change, this may have been expected and everything is okay. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected for appear as subbullets. - [frame_methods.Fillna.time_fillna](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.Fillna.time_fillna) - [inplace=True; dtype='object'](https://asv-runner.github.io/asv-collection/pandas/#frame_methods.Fillna.time_fillna?p-inplace=True&p-dtype=%27object%27) Subsequent benchmarks may have skipped some commits. The link below lists the commits that are between the two benchmark runs where the regression was identified. [Commit Range](https://github.com/pandas-dev/pandas/compare/b3b97dcb723f86331b2276cc2809bd6506d472b9...590d6edb4c149eba38640d9a94f4de760d0a9fb5) cc @phofl
[ "Missing-data", "Performance", "Regression" ]
0
0
0
0
0
0
0
0
[ "I’ll dig deeper later, but pretty sure that this is expected. ", "I can't reproduce this locally, this might be related to how we run benchmarks maybe?\r\n\r\nLocally, the example actually got faster, which is kind of what I would expect based on the fact that downcasting isn't cheap", "I think this is due to the use of inplace within ASV. When we downcasted, future calls would be faster. If I add a copy:\r\n\r\n df.copy(deep=True).ffill(inplace=inplace)\r\n\r\nThen I get \r\n\r\n```\r\n195 ms ± 3.72 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) <-- prior to #57328 \r\n146 ms ± 2.02 ms per loop (mean ± std. dev. of 7 runs, 10 loops each) <-- main\r\n```" ]
2,152,817,216
57,618
Remove inline from khash_python
closed
2024-02-25T15:33:34
2024-02-26T15:59:41
2024-02-26T11:32:24
https://github.com/pandas-dev/pandas/pull/57618
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57618
https://github.com/pandas-dev/pandas/pull/57618
WillAyd
4
@DeaMariaLeon noted that #57575 caused a slight regression in the benchmarks. This is the only thing from that PR that could reasonably affect performance in any way
[]
0
0
0
0
0
0
0
0
[ "can you link a benchmark?", "I don't have the direct link but this is what conbench showed\r\n\r\n![image](https://github.com/pandas-dev/pandas/assets/609873/5859a442-f3d7-4c72-8b59-570f3e68b590)\r\n", "thx", "Nice! @WillAyd \r\n![Screenshot 2024-02-26 at 16 58 43](https://github.com/pandas-dev/pandas/assets/11835246/b6dad7da-eb0a-4c68-8cf1-1816435b5173)\r\n" ]
2,152,726,808
57,617
ENH: `(Styler|DataFrame).to_typst()`
closed
2024-02-25T11:48:15
2025-02-01T19:16:47
2025-02-01T19:16:47
https://github.com/pandas-dev/pandas/issues/57617
true
null
null
janosh
2
### Feature Type - [X] Adding new functionality to pandas - [ ] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description typst is a new markup language for scientific documents https://github.com/typst/typst. i think of it as latex for the 21 century. ### Feature Description i've used `(df|styler).to_latex` many times and would find an equivalent `(df|styler).to_typst` equally useful now that i've transitioned to Typst. ### Alternative Solutions export to JSON/CSV and [use Typst native JSON/CSV import feature](https://typst.app/docs/reference/data-loading) and generate table in Typst rather than in pandas. drawback: looses styling and all customization options available with `Styler` ### Additional Context _No response_
[ "Enhancement", "Needs Discussion", "IO LaTeX" ]
4
0
0
0
0
0
0
0
[ "Thanks for the request. I think we'll have to balance the popularity of the format vs the maintenance burden of `to_typst`. If adding in `to_typst` is not at all involved, then I think I'd be open to it. However, if it rivals the implementation `to_latex` while being an order of magnitude less popular (not sure - but I'd guess that's currently the case), then I think we should hold off.\r\n\r\n[pandoc](https://pandoc.org/) now support typst - can you try converting the output of `to_latex` to typst using that for your use cases and let us know if any difficulties are encountered?\r\n\r\ncc @attack68 ", "Agreed, nothing more to add. I think we would also need multiple developers familiar with typst to ensure that any development was pursuing the right direction.\r\n\r\n`to_latex` was a huge implementation: #40422 with many follow ups and add ons.\r\n`to_string` was a very quick job: #44502 \r\n\r\nA compromise would be allow a PR to be submitted on the scale of `to_string` and see if there are any follow up issues from users." ]
2,152,685,560
57,616
Doc: resolve GL08 for pandas.Timedelta.microseconds, unit & value
closed
2024-02-25T09:54:14
2024-02-28T17:34:36
2024-02-28T17:34:29
https://github.com/pandas-dev/pandas/pull/57616
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57616
https://github.com/pandas-dev/pandas/pull/57616
lamdang2k
1
- [x] xref #57443 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "Timedelta" ]
0
0
0
0
0
0
0
0
[ "Thanks @lamdang2k " ]
2,152,677,179
57,615
Doc: fixing RT03 errors for pandas.DataFrame.expanding
closed
2024-02-25T09:31:13
2024-03-10T20:00:29
2024-02-26T23:05:05
https://github.com/pandas-dev/pandas/pull/57615
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57615
https://github.com/pandas-dev/pandas/pull/57615
jordan-d-murphy
2
All RT03 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=RT03 pandas.DataFrame.expanding - [x] xref https://github.com/pandas-dev/pandas/issues/57416 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "Window" ]
0
0
0
0
0
0
0
0
[ "@mroeschke merge conflicts resolved here as well\r\n", "Thanks @jordan-d-murphy " ]
2,152,670,016
57,614
DOC: Add `DataFrame.isetitem` method
closed
2024-02-25T09:10:37
2024-02-28T03:23:23
2024-02-27T16:52:07
https://github.com/pandas-dev/pandas/pull/57614
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57614
https://github.com/pandas-dev/pandas/pull/57614
luke396
2
- [x] closes #57602 (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", "Indexing" ]
0
0
0
0
0
0
0
0
[ "You need to fix the below error for passing all the checks\r\n\r\n2 Errors found for `pandas.DataFrame.isetitem`:\r\n SA01 See Also section not found\r\n EX01 No examples section found\r\n", "Thanks @luke396 " ]
2,152,662,440
57,613
fix SA01 error for pandas.ArrowDtype
closed
2024-02-25T08:46:35
2024-02-26T18:23:47
2024-02-26T18:11:03
https://github.com/pandas-dev/pandas/pull/57613
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57613
https://github.com/pandas-dev/pandas/pull/57613
jordan-d-murphy
2
All SA01 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=SA01 pandas.ArrowDtype - [x] xref https://github.com/pandas-dev/pandas/issues/57417 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n\r\n", "Thanks @jordan-d-murphy " ]
2,152,652,969
57,612
Doc: Fix PR07 errors for pandas.DataFrame.align
closed
2024-02-25T08:14:36
2024-02-26T18:24:32
2024-02-26T18:14:28
https://github.com/pandas-dev/pandas/pull/57612
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57612
https://github.com/pandas-dev/pandas/pull/57612
jordan-d-murphy
2
All PR07 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=PR07 pandas.DataFrame.align - [x] xref https://github.com/pandas-dev/pandas/issues/57420 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n", "Thanks @jordan-d-murphy " ]
2,152,645,787
57,611
Doc: fix PR01 docstring errors for pandas.CategoricalIndex.equals and pandas.CategoricalIndex.map
closed
2024-02-25T07:50:42
2024-03-11T00:19:59
2024-02-26T23:05:32
https://github.com/pandas-dev/pandas/pull/57611
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57611
https://github.com/pandas-dev/pandas/pull/57611
jordan-d-murphy
3
All PR01 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=ES01 pandas.CategoricalIndex.equals 2. scripts/validate_docstrings.py --format=actions --errors=ES01 pandas.CategoricalIndex.map - [x] xref https://github.com/pandas-dev/pandas/issues/57438 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "Categorical" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n", "@mroeschke merge conflicts have been resolved ", "Thanks @jordan-d-murphy " ]
2,152,638,814
57,610
Doc: fix ES01 for pandas.CategoricalDtype
closed
2024-02-25T07:24:48
2024-02-26T18:23:35
2024-02-26T17:59:11
https://github.com/pandas-dev/pandas/pull/57610
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57610
https://github.com/pandas-dev/pandas/pull/57610
jordan-d-murphy
2
All ES01 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=ES01 pandas.CategoricalDtype - [x] xref #57440 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n", "Thanks for the effort here, but it was decided that ES01 is not going to be enforced so closing. Happy to have PRs on other doc issues!" ]
2,152,624,514
57,609
Doc: resolve GL08 for pandas.core.groupby.SeriesGroupBy.value_counts
closed
2024-02-25T06:31:48
2024-02-26T22:34:49
2024-02-26T22:34:41
https://github.com/pandas-dev/pandas/pull/57609
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57609
https://github.com/pandas-dev/pandas/pull/57609
jordan-d-murphy
3
All GL08 Errors resolved in the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.core.groupby.SeriesGroupBy.value_counts - [x] xref https://github.com/pandas-dev/pandas/issues/57443 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "Groupby", "CI" ]
0
0
0
0
0
0
0
0
[ "pre-commit.ci autofix\r\n\r\n", "updated this PR based on your feedback, @rhshadrach can you take another look?", "Thanks @jordan-d-murphy " ]
2,152,610,072
57,608
BUG: queries on categorical string columns in HDFStore.select() return unexpected results
closed
2024-02-25T05:34:44
2025-05-20T15:57:36
2025-05-20T15:57:36
https://github.com/pandas-dev/pandas/issues/57608
true
null
null
orionbelt
1
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [ ] 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 models = pd.api.types.CategoricalDtype(categories=['name','longname','verylongname']) df = pd.DataFrame({'modelId':['name','longname','longname'], 'value' :[1,2,3]} ).astype({'modelId':models,'value':int}) with pd.HDFStore('test.h5','w') as store: store.append('df',df,data_columns=['modelId']) with pd.HDFStore('test.h5','r') as store: model = 'name' print(store.select('df', 'modelId == model')) model = 'longname' print(store.select('df', 'modelId == model')) model = 'verylongname' print(store.select('df', 'modelId == model')) ``` ### Issue Description This seems to be the same or very similar to bug #39189 (regression?) I encountered the same behavior under pandas 2.2.0 and 2.2.1 ### Expected Behavior The DataFrame stored in the HDF store is: ``` >>> df 0 name 1 1 longname 2 2 longname 3 ``` The 3 print statements give: ``` # Below should have matched row 0 instead of Empty >>> model = 'name' >>> print(store.select('df', 'modelId == model')) Empty DataFrame Columns: [modelId, value] Index: [] # Below matched row 0 but should have matched rows 1 and 2 >>> model = 'longname' >>> print(store.select('df', 'modelId == model')) modelId value 0 name 1 # This is correct >>> model = 'verylongname' >>> print(store.select('df', 'modelId == model')) Empty DataFrame Columns: [modelId, value] Index: [] ``` ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.8.final.0 python-bits : 64 OS : Linux OS-release : 6.1.69-gentoo-dist-hardened Version : #1 SMP PREEMPT_DYNAMIC Thu Jan 18 22:03:57 CET 2024 machine : x86_64 processor : AMD Ryzen 5 3600X 6-Core Processor byteorder : little LC_ALL : en_US.UTF-8 LANG : en_BE.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.1 numpy : 1.26.4 pytz : 2024.1 dateutil : 2.8.2 setuptools : 69.0.3 pip : None Cython : 3.0.8 pytest : 7.4.4 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : 3.1.9 lxml.etree : 4.9.4 html5lib : 1.1 pymysql : None psycopg2 : None jinja2 : 3.1.3 IPython : 8.21.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : 1.3.7 dataframe-api-compat : None fastparquet : None fsspec : 2024.2.0 gcsfs : None matplotlib : 3.8.2 numba : 0.59.0 numexpr : 2.9.0 odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.12.0 sqlalchemy : 2.0.25 tables : 3.9.2 tabulate : 0.9.0 xarray : 2024.1.1 xlrd : 2.0.1 zstandard : 0.22.0 tzdata : None qtpy : 2.4.1 pyqt5 : None </details>
[ "Bug", "IO HDF5", "Categorical" ]
0
0
0
0
0
0
0
0
[ "Thanks for the report! Confirmed on main. It indeed looks like this is due to categorical as working with just strings gives the correct result. Further investigations and PRs to fix are welcome!" ]
2,152,574,835
57,607
BUG: Possible bad api side effect of replacing FrozenList with tuple
closed
2024-02-25T03:02:35
2024-04-11T15:38:22
2024-04-11T15:38:22
https://github.com/pandas-dev/pandas/issues/57607
true
null
null
dalejung
8
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [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({'name': ['dale', 'frank'], 'age': [10, 20]}) df = df.set_index('name') index_names = df.index.names df = df.reset_index() df.set_index(index_names) # KeyError: "None of [('name',)] are in the columns" ``` ### Issue Description This might not be considered a bug, but I would expect there to be symmetry in `df.set_index` and `df.index.names`. Previously when `index.names` was a FrozenList, this would work. However a tuple has different semantics than a list throughout pandas. ### Expected Behavior I would expect `Index.names` to work for `set_index`. ### Installed Versions <details> INSTALLED VERSIONS ------------------ commit : f01ae209da4ecca9c7b260511886d86e61856c21 python : 3.11.7.final.0 python-bits : 64 OS : Linux OS-release : 6.7.4-arch1-1 Version : #1 SMP PREEMPT_DYNAMIC Mon, 05 Feb 2024 22:07:49 +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+431.gf01ae209da numpy : 1.24.4 pytz : 2023.3 dateutil : 2.8.2 setuptools : 69.1.1 pip : 24.0 Cython : 3.0.8 pytest : 7.4.0 hypothesis : 6.98.11 sphinx : 6.2.1 blosc : None feather : None xlsxwriter : 3.1.0 lxml.etree : 4.9.2 html5lib : 1.1 pymysql : 1.0.3 psycopg2 : 2.9.6 jinja2 : 3.1.2 IPython : 8.22.1 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : 1.3.7 fastparquet : 2023.4.0 fsspec : 2023.5.0 gcsfs : 2023.5.0 matplotlib : 3.7.1 numba : 0.57.0 numexpr : 2.8.4 odfpy : None openpyxl : 3.1.2 pyarrow : 16.0.0.dev175+g2d44818d0 pyreadstat : 1.2.1 python-calamine : None pyxlsb : 1.0.10 s3fs : 2023.5.0 scipy : 1.10.1 sqlalchemy : 2.0.14 tables : 3.8.0 tabulate : 0.9.0 xarray : 2023.5.0 xlrd : 2.0.1 zstandard : 0.21.0 tzdata : 2023.3 qtpy : 2.4.0 pyqt5 : None </details>
[ "Bug", "Blocker", "Needs Discussion", "Index" ]
0
0
0
0
0
0
0
0
[ "cc @mroeschke @jorisvandenbossche", "https://github.com/search?q=%22index.names+%3D%3D+%5BNone%5D%22&type=code\r\n\r\nfwiw checking for `df.index.names == [None]` happens pretty frequently. Variants of this type of error is how I ran into the change originally in private repo. Just ran into it with hvplot. The fixes to these are obviously simple, you just wrap `index.names` in a `list`. But unsure what the upside of the change is.", "Maybe we could return a `list` here instead of a tuple since `FrozenList` was originally a list subclass.\r\n\r\nSince `codes/names/levels` that returned this before are not writable, maybe we don't need the mutability anymore", "> maybe we don't need the mutability anymore\r\n\r\nWhat do you mean exactly with this?", "Consider something like this\r\n\r\n```\r\ndf.index.names[0] = \"a\"\r\n```\r\n\r\nCurrently such code fails, because the FrozenList is not mutable (and also with the tuple it fails). But if this would return a list instead, that would actually \"work\", in the sense of not raising an error anymore, but I suppose it would not actually update the names?\r\n", "> What do you mean exactly with this?\r\n\r\nSorry I meant immutability.\r\n\r\n> Consider something like this\r\n\r\nIt appears for `MultiIndex` that codes/levels/names are backed by private _codes/_level/_names attributes. If we have the public attributes return lists and the private attributes use tuples we can still achieve \"immutability\" as before. Here's an example from a branch I have that implements this\r\n\r\n```python\r\nIn [5]: df = pd.DataFrame([1], index=pd.MultiIndex(codes=[[0]], levels=[[\"a\"]], names=[0]))\r\n\r\nIn [6]: df\r\nOut[6]: \r\n 0\r\n0 \r\na 1\r\n\r\nIn [9]: df.index.names[0] = \"a\"\r\n\r\nIn [10]: df.index\r\nOut[10]: \r\nMultiIndex([('a',)],\r\n names=[0])\r\n```", "Yes, but so that has the behaviour that I mentioned above of _appearing to work_ (because it no longer raises an error about being immutable), while not actually working.\r\n\r\nI personally think it is perfectly fine that this doesn't work (that's how it always has been, and there are other APIs to change the name), but IMO it would be a UX regression if it no longer fails loudly.", "Maybe we also just restore the FrozenList? Not a strong preference but I think the pattern the OP established is pretty reasonable. I would really never expect `df.set_index(index_names)` to act like a tuple indexer" ]
2,152,556,676
57,606
TYP: misc annotations
closed
2024-02-25T01:44:07
2024-04-07T10:59:14
2024-02-26T18:28:44
https://github.com/pandas-dev/pandas/pull/57606
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57606
https://github.com/pandas-dev/pandas/pull/57606
twoertwein
1
to pass more of the pandas-stubs tests.
[ "Typing" ]
0
0
0
0
0
0
0
0
[ "Thanks @twoertwein " ]
2,152,525,045
57,605
DOC: fix RT03 for CategoricalIndex.set_categories, DataFrame.astype, DataFrame.at_time and DataFrame.ewm
closed
2024-02-24T23:49:36
2024-02-26T18:29:49
2024-02-26T18:29:43
https://github.com/pandas-dev/pandas/pull/57605
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57605
https://github.com/pandas-dev/pandas/pull/57605
bergnerjonas
1
Resolve all RT03 errors for the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=RT03 pandas.CategoricalIndex.set_categories (already valid) 2. scripts/validate_docstrings.py --format=actions --errors=RT03 pandas.DataFrame.astype 3. scripts/validate_docstrings.py --format=actions --errors=RT03 pandas.DataFrame.at_time 4. scripts/validate_docstrings.py --format=actions --errors=RT03 pandas.DataFrame.ewm - [ ] 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
[ "Thanks @bergnerjonas " ]
2,152,455,223
57,604
DOC: ES01 fix for HDFS Methods
closed
2024-02-24T19:30:39
2024-02-28T05:20:24
2024-02-26T17:58:50
https://github.com/pandas-dev/pandas/pull/57604
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57604
https://github.com/pandas-dev/pandas/pull/57604
YashpalAhlawat
1
All ES01 Errors resolved in the following cases: scripts/validate_docstrings.py --format=actions --errors=ES01 pandas.HDFStore.put scripts/validate_docstrings.py --format=actions --errors=ES01 pandas.HDFStore.get scripts/validate_docstrings.py --format=actions --errors=ES01 pandas.HDFStore.info scripts/validate_docstrings.py --format=actions --errors=ES01 pandas.HDFStore.keys - [x] xref #57440 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[ "Thanks for the effort here, but it was decided that ES01 is not going to be enforced so closing. Happy to have PRs on other doc issues!" ]
2,152,399,634
57,603
DOC: fix RT03 for pandas.Index.to_numpy and pandas.Categorial.set_categories
closed
2024-02-24T16:48:03
2024-02-24T23:16:57
2024-02-24T18:34:28
https://github.com/pandas-dev/pandas/pull/57603
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57603
https://github.com/pandas-dev/pandas/pull/57603
bergnerjonas
1
Resolve all errors for the following cases: 1. scripts/validate_docstrings.py --format=actions --errors=RT03 pandas.Index.to_numpy 2. scripts/validate_docstrings.py --format=actions --errors=RT03 pandas.Categorical.set_categories Also fixes typos and wrong default value in docstring of pandas.Categorical.set_categories. - [ ] 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
[ "Thanks @bergnerjonas " ]
2,152,384,686
57,602
DOC: missed doc for `DataFrame.isetitem` in https://pandas.pydata.org/docs/search.html?q=isetitem
closed
2024-02-24T16:21:33
2024-02-27T16:52:08
2024-02-27T16:52:08
https://github.com/pandas-dev/pandas/issues/57602
true
null
null
anmyachev
1
### 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 N/A ### Documentation problem Missing documentation for a public method. ### Suggested fix for documentation Since the method is public, its documentation should appear in https://pandas.pydata.org/docs/search.html?q=isetitem search.
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "https://pandas.pydata.org/pandas-docs/version/2.1/reference/api/pandas.DataFrame.isetitem.html not in v2.2 and dev version." ]
2,152,336,608
57,601
DOC: Fixing GL08 errors for pandas.ExcelFile.sheet_names and pandas.MultiIndex.codes
closed
2024-02-24T14:19:18
2024-02-28T03:45:10
2024-02-27T22:10:03
https://github.com/pandas-dev/pandas/pull/57601
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57601
https://github.com/pandas-dev/pandas/pull/57601
thomasdamcevski
1
Resolved GL08 errors for the following: 1. scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.ExcelFile.sheet_names 2. scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.MultiIndex.codes Ref: #57443 - [ ] 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 - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs", "CI", "IO Excel", "MultiIndex" ]
0
0
0
0
0
0
0
0
[ "Thanks @thomasdamcevski and @bergnerjonas " ]
2,152,302,462
57,600
DOC: Whatsnew notable bugfix on groupby behavior with unobserved groups
closed
2024-02-24T13:02:58
2024-02-27T08:43:05
2024-02-26T18:31:47
https://github.com/pandas-dev/pandas/pull/57600
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57600
https://github.com/pandas-dev/pandas/pull/57600
rhshadrach
4
- [ ] closes #xxxx (Replace xxxx with the GitHub issue number) - [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature. Ref: https://github.com/pandas-dev/pandas/pull/55738#issuecomment-1937085332 I made the section just focus on the unobserved fixes, leaving the dropna bugfixes where they are (they are quite minor). cc @jorisvandenbossche
[ "Docs", "Groupby" ]
0
0
0
0
0
0
0
0
[ "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57600/", "Thanks @rhshadrach ", "Thank @rhshadrach for the follow-up!" ]
2,152,276,724
57,599
REF: Move compute to BinGrouper.result_index_and_ids
closed
2024-02-24T11:59:24
2024-02-24T20:45:53
2024-02-24T18:29:05
https://github.com/pandas-dev/pandas/pull/57599
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57599
https://github.com/pandas-dev/pandas/pull/57599
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. BaseGrouper does the compute in `result_index_and_ids` and other methods utilize this result. This refactors so BinGrouper behaves the same.
[ "Refactor", "Groupby" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,152,273,541
57,598
CLN: Use group_info less
closed
2024-02-24T11:47:58
2024-02-24T20:46:08
2024-02-24T18:27:37
https://github.com/pandas-dev/pandas/pull/57598
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57598
https://github.com/pandas-dev/pandas/pull/57598
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. My goal is to remove redundant methods in BaseGrouper / Grouping - group_info seems like a good candidate.
[ "Groupby", "Clean" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,152,267,240
57,597
DOC: ES01 fix for to_csv method
closed
2024-02-24T11:26:06
2024-02-26T17:58:28
2024-02-26T17:58:27
https://github.com/pandas-dev/pandas/pull/57597
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57597
https://github.com/pandas-dev/pandas/pull/57597
YashpalAhlawat
1
All ES01 Errors resolved in the following cases: scripts/validate_docstrings.py --format=actions --errors=ES01 pandas.DataFrame.to_csv - [x] xref #57440 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[]
0
0
0
0
0
0
0
0
[ "Thanks for the effort here, but it was decided that ES01 is not going to be enforced so closing. Happy to have PRs on other doc issues!" ]
2,152,250,220
57,596
BUG: Unexpected behaviour when inserting timestamps into Series
open
2024-02-24T10:31:34
2024-12-16T12:49:54
null
https://github.com/pandas-dev/pandas/issues/57596
true
null
null
KowalMar
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. - [ ] 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 dt = pd.to_datetime(['2024-02-24 10:00']) s = pd.Series([1],index=dt) s.loc['2024-02-24 9:57'] = None # is inserted into s print(s) s.loc['2024-02-24 10:2:30'] = None # is inserted into s print(s) s.loc['2024-02-24 10:08'] = None # is _not_ inserted into s print(s) s.loc['2024-02-24 10:08:00'] = None # is inserted into s print(s) ``` ### Issue Description When inserting timestamps into a pandas Series, beginning with the format 'yyyy-mm-dd hh:mm', they are inserted correctly, until first time switching to format 'yyyy-mm-dd hh:mm:ss'. From then on format 'yyyy-mm-dd hh:mm' is silently not inserted, ending with seconds required. Not sure if this is intended, unexpected behaviour in my opinion. ### Expected Behavior Insert timestamps as long as their format is parsed unambiguously. ### Installed Versions <details> pandas 2.1.4 py311hf62ec03_0 </details>
[ "Bug", "Needs Triage" ]
1
0
0
0
0
0
0
0
[ "cc @jbrockmendel ", "take", "This is a tough one. The '2024-02-24 10:08' case goes through the `if self._can_partial_date_slice(reso):` path in DatetimeIndex.get_loc, which in this case returns an empty array. One possible place to catch this would be to check for it in `Loc._get_setitem_indexer`. Not sure if there is a less-ugly/special-case-y place to do it.", "Correct me if I'm wrong, from what I understand, the `if self._can_partial_date_slice(reso):` (in DatetimeIndex.get_loc) checks `if reso > self._resolution_obj` (in DatetimeIndexOpsMixin._can_partial_date_slice), with `reso` being the resolution of the current key being checked and `self._resolution_obj` being the lowest resolution thus far. If the `if self._can_partial_date_slice(reso):` returns `True`, it will then do `return self._partial_date_slice(reso, parsed)` (in DatetimeIndexOpsMixin._partial_date_slice), which returns the empty array. Would it be possible to just convert all entries to be the same as the lowest resolution thus far, e.g. if the lowest resolution thus far is `Resolution.RESO_SEC`, then any entries before and after would be converted into `Resolution.RESO_SEC`?", "Changing this within DTI.get_loc doesn't make sense; you'd need to catch it elsewhere", "`_LocationIndexer._get_setitem_indexer` calls `_LocIndexer._convert_to_indexer` which goes through the `if is_scalar(key) or (isinstance(labels, MultiIndex) and is_hashable(key) and not contains_slice):` check. As `is_scalar(key)` is True, it returns `return labels.get_loc(key)` which is an empty array in this case, would it be possible to catch it here by checking if the array is empty, if it is then `return {\"key\": key}`?\r\n\r\nJust wondering if catching it in `_LocationIndexer._get_setitem_indexer` could be repeating the checks done at `_LocIndexer._convert_to_indexer`, unless there is another way of approaching it." ]
2,151,945,073
57,595
PERF: groupby(...).__len__
closed
2024-02-23T23:21:07
2024-02-24T00:24:42
2024-02-24T00:10:17
https://github.com/pandas-dev/pandas/pull/57595
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57595
https://github.com/pandas-dev/pandas/pull/57595
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. Enabled by #55738. Prior to that, `ngroups` was not reliable. ``` size = 100_000 df = pd.DataFrame( { "a": np.random.randint(0, 100, size), "b": np.random.randint(0, 100, size), } ) %timeit len(df.groupby(["a", "b"])) # 161 ms ± 962 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) <-- main # 4.96 ms ± 229 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) <-- PR ```
[ "Groupby", "Performance" ]
0
0
0
0
0
0
0
0
[ "Thanks @rhshadrach " ]
2,151,926,578
57,594
BUG: df.plot makes a shift to the right if frequency multiplies to n > 1
open
2024-02-23T22:58:54
2024-05-21T16:09:03
null
https://github.com/pandas-dev/pandas/issues/57594
true
null
null
natmokval
5
This bug exists on the latest version of pandas and might be related to the bug reported in #51425. `df.plot` DataFrame with `PeriodIndex` works well for frequency with `n=1`, while fоr frequency that multiplies on `n>1` we have a shift to the right. **Reproducible Examples:** if freq="7h" ``` from pandas import * import numpy as np idx = period_range("01/01/2000", freq='7h', periods=4) df = DataFrame( np.array([0, 1, 0, 1]), index=idx, columns=["A"], ) df.plot() print(df) ``` the plotting starts from 06:00 <img width="552" alt="res_7h" src="https://github.com/pandas-dev/pandas/assets/91160475/d09c229b-d665-4602-aaec-18f8bc9a6fab"> if freq="2h" ``` idx = period_range("01/01/2000", freq='2h', periods=4) df = DataFrame( np.array([0, 1, 0, 1]), index=idx, columns=["A"], ) df.plot() print(df) ``` we have a shift on +1 hour <img width="573" alt="res_2h" src="https://github.com/pandas-dev/pandas/assets/91160475/11dc9fe2-2c3c-42f4-989e-cc0e1ed053b3"> But if freq="h" ``` idx = period_range("01/01/2000", freq='h', periods=4) df = DataFrame( np.array([0, 1, 0, 1]), index=idx, columns=["A"], ) df.plot() print(df) ``` the result looks okay: <img width="560" alt="res_h" src="https://github.com/pandas-dev/pandas/assets/91160475/12b9b607-74c3-4e26-a79a-b965a22ff4b8"> **Expected Behavior:** I think for both `freq="7h"` and `freq="2h"` we should start plotting from the point `(00:00, 0.0)` as we do for `freq="h"` In case DataFrame with `DatetimeIndex` plotting works correct, e.g. ``` idx = date_range("01/01/2000", freq='7h', periods=4) df = DataFrame( np.array([0, 1, 0, 1]), index=idx, columns=["A"], ) df.plot() print(df) ``` output: <img width="550" alt="res_7h_dr" src="https://github.com/pandas-dev/pandas/assets/91160475/8206da68-5462-4584-b3b7-57ac8ad528dc">
[ "Bug", "Visualization" ]
0
0
0
0
0
0
0
0
[ "take", "take", "take", "take", "@natmokval should this be closed now that #58322 is merged?" ]
2,151,884,557
57,593
DOC: Documentation website says version 2.2 is unstable
closed
2024-02-23T22:12:24
2025-06-02T17:15:14
2025-06-02T17:15:13
https://github.com/pandas-dev/pandas/issues/57593
true
null
null
billtubbs
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/index.html ### Documentation problem A large red banner says 'This is documentation for an unstable development version.' Below that, a small drop-down menu says '2.2 (stable)'. Clicking the 'Switch to Stable Version' button simply returns to the same page. <img width="1422" alt="Screenshot 2024-02-23 at 14 06 23" src="https://github.com/pandas-dev/pandas/assets/7958850/c223ab99-ebea-47a3-99f3-b330c97c5dcf"> ### Suggested fix for documentation Modify the website settings so that version 2.2 is identified to be stable (or have the button redirect users to the 2.1.4 documentation).
[ "Docs", "Blocker" ]
12
0
0
0
0
0
0
0
[ "Hm, I'm a little conused by why this is happening?\r\n\r\nhttps://github.com/pydata/pydata-sphinx-theme/issues/1552 seems to be related\r\n\r\ncc @jorisvandenbossche @mroeschke ", "I can confirm. It's very visually disrupting. ", "It's not directly clear to me why this is happening for 2.2.1 (https://pandas.pydata.org/pandas-docs/version/2.2.1/index.html), but not for 2.2.0 (https://pandas.pydata.org/pandas-docs/version/2.2.0/index.html), as both use the exact same version of the sphinx theme", "Ah, I suppose this is because the javascript code that decides whether to show the warning or not is \"comparing\" the versions (not just checking exact equality of the strings, https://github.com/pydata/pydata-sphinx-theme/blob/fa456d0ea9fcfd4363f7af9cf43f7e84002d19eb/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js#L470-L474), and so \"2.2.0\" was comparable to \"2.2\", but \"2.2.1\" no longer compares equal (just a hypothesis, didn't actually check)", "As a temporary fix, I patched the sources on our web server to:\r\n\r\n- edit `pandas-docs/version/2.2.1/_static/documentation_options.js` to say `VERSION: '2.2'` instead of `'2.2.1'`\r\n- Run `find ./ -type f -exec sed -i \"s/documentation_options.js?v=16656018/documentation_options.js?v=166560180/g\" {} \\;` (just adding a 0 to the `?v=` number, to ensure the browser fetches the new one, otherwise even a hard refresh doesn't help)\r\n\r\nWe should still further investigate how to fix it properly for the next release", "If we're not able to fix this for the next release, is it just fine to turn off the warning banner for now?\r\n\r\nI think that's relatively easy to do. I'm not sure I can help much with debugging this further - I can't really read javascript.", "> If we're not able to fix this for the next release, is it just fine to turn off the warning banner for now?\r\n> \r\n> I think that's relatively easy to do. I'm not sure I can help much with debugging this further - I can't really read javascript.\r\n\r\nI do not see the warning banner anymore on stable docs, seems like Joris has fixed it.\r\nIs this still considered a blocker?", "I don't see it either anymore so closing", "Looks like this is still there.\r\n\r\n@mroeschke @jorisvandenbossche \r\n\r\nWe should either patch or disable the banner altogether.", "I again quickly patched the web sources for 2.2.2, but yes, we should fix this more permanently. Disabling the banner until we find a better solution might be the best option short term.", "I don't see this anymore on https://pandas.pydata.org/docs/index.html so this might have gotten fixed in the meantime. Closing" ]
2,151,869,476
57,592
BUG: DataFrame([Series with different CategoricalIndexes]) results in non-Categorical columns
open
2024-02-23T21:59:00
2024-02-26T22:30:03
null
https://github.com/pandas-dev/pandas/issues/57592
true
null
null
mroeschke
3
```python In [1]: import pandas as pd In [4]: s1 = pd.Series([1, 2], index=pd.CategoricalIndex(["a", "b"])) In [5]: s2 = pd.Series([3, 4], index=pd.CategoricalIndex(["a", "c"])) In [6]: pd.DataFrame([s1, s2]).columns Out[6]: Index(['a', 'b', 'c'], dtype='object') ``` I would have expected `CategoricalIndex(['a', 'b', 'c'])`
[ "Categorical", "DataFrame", "Constructors" ]
0
0
0
0
0
0
0
0
[ "Hi @mroeschke, can I take this issue? If the answer is yes, what is the expected behavior when you pass a list series with and without categorical indices? Shouldn't we check the whole list? something like this:\r\n\r\n`all_categorical = all(isinstance(s.index, pandas.CategoricalIndex) for s in data)\r\n`\r\n\r\nand later in the code, change the columns to the right type:\r\n\r\n```\r\nif all_categorical:\r\n columns = pandas.CategoricalIndex(columns)\r\n```", "Sure feel free to work on it (although I am not sure this will be an easy issue to fix). If the indexes are of mixed types the result should be `Index[object]`", "I've just created the PR. Please let me know if the changes make sense. As it is, columns will return a ``Index[object]`` if the indices are mixed, and a ``CategoricalIndex[category]``, if all the series had categorical indices. \r\n\r\nI do think it also makes sense to add a test to check this scenario. " ]
2,151,864,153
57,591
PERF: groupby.first and groupby.last fallback to apply for EAs
open
2024-02-23T21:54:21
2024-02-25T21:44:31
null
https://github.com/pandas-dev/pandas/issues/57591
true
null
null
rhshadrach
3
#57589 showed groupby.first and groupby.last are falling back to apply for certain EAs. This should not fallback.
[ "Groupby", "Performance", "ExtensionArray", "Reduction Operations" ]
0
0
0
0
0
0
0
0
[ "Do you know the type of eas that fall back?", "From the CI run in the linked PR:\r\n\r\n```\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[decimal128(7, 3)] - NotImplementedError\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[string] - NotImplementedError\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[binary] - NotImplementedError\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[time32[s]] - NotImplementedError\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[time32[ms]] - NotImplementedError\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[time64[us]] - NotImplementedError\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[time64[ns]] - NotImplementedError\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[date32[day]] - NotImplementedError\r\nFAILED pandas/tests/extension/test_arrow.py::TestArrowArray::test_groupby_agg_extension[date64[ms]] - NotImplementedError\r\nFAILED pandas/tests/extension/test_numpy.py::TestNumpyExtensionArray::test_groupby_agg_extension[float] - NotImplementedError: function is not implemented for this dtype: float64\r\nFAILED pandas/tests/extension/test_numpy.py::TestNumpyExtensionArray::test_groupby_agg_extension[object] - NotImplementedError: function is not implemented for this dtype: object\r\nFAILED pandas/tests/extension/test_sparse.py::TestSparseArray::test_groupby_agg_extension[0] - NotImplementedError: function is not implemented for this dtype: Sparse[float64, 0]\r\nFAILED pandas/tests/extension/test_sparse.py::TestSparseArray::test_groupby_agg_extension[nan] - NotImplementedError: function is not implemented for this dtype: Sparse[float64, nan]\r\nFAILED pandas/tests/extension/decimal/test_decimal.py::TestDecimalArray::test_groupby_agg_extension - NotImplementedError: function is not implemented for this dtype: decimal\r\nFAILED pandas/tests/extension/test_interval.py::TestIntervalArray::test_groupby_agg_extension - NotImplementedError: function is not implemented for this dtype: interval[float64, right]\r\nFAILED pandas/tests/extension/json/test_json.py::TestJSONArray::test_groupby_agg_extension - NotImplementedError: function is not implemented for this dtype: json\r\n= 16 failed, 221228 passed, 6664 skipped, 1811 xfailed, 94 xpassed, 40 warnings in 1525.24s (0:25:25) =\r\n```", "Thx, none of those is really surprising unfortunately " ]
2,151,827,239
57,590
RLS: 2.2.2
closed
2024-02-23T21:23:58
2024-04-11T00:02:41
2024-04-11T00:02:41
https://github.com/pandas-dev/pandas/issues/57590
true
null
null
lithomas1
4
Estimated date: 4/10/2024 (after numpy 2.0rc1)
[ "Release" ]
0
0
0
0
0
0
0
0
[ "@pandas-dev/pandas-core \r\n\r\nLooks like there hasn't been much merged to 2.2.2, so I'll probably wait until there's either enough stuff merged or numpy releases their 2.0.0rc1 to put this out.", "Release is target for next Wednesday 4/10/2024", "@pandas-dev/pandas-core \r\n\r\nJust a friendly reminder that the release is targetted for today.\r\n\r\n(If there's any objections, now would be the time to speak. I'm planning on cutting the release around 1-1:30ish)", "announced" ]
2,151,803,166
57,589
CLN: groupby.first/last unused compat
closed
2024-02-23T21:09:33
2024-02-28T22:43:09
2024-02-23T21:54:30
https://github.com/pandas-dev/pandas/pull/57589
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57589
https://github.com/pandas-dev/pandas/pull/57589
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. It used to be that any op winding up in `_cython_agg_general` needed a fallback. This is no longer the case since `first` and `last` now handle `object` dtype in the Cython code and `axis=1` has been removed.
[ "Groupby", "Clean" ]
0
0
0
0
0
0
0
0
[ "I was wrong - EAs are still falling back to apply. Opened #57591 " ]
2,151,726,399
57,588
PERF: Return a RangeIndex from __getitem__ with a bool mask when possible
closed
2024-02-23T20:08:34
2024-03-02T02:24:35
2024-03-02T02:24:32
https://github.com/pandas-dev/pandas/pull/57588
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57588
https://github.com/pandas-dev/pandas/pull/57588
mroeschke
0
Discovered in https://github.com/pandas-dev/pandas/pull/57441
[ "Performance", "Index" ]
0
0
0
0
0
0
0
0
[]
2,151,370,256
57,587
BUG: `df.plot` works differently for `freq="h"` and `freq="60min"`
open
2024-02-23T15:59:15
2024-05-21T16:23:36
null
https://github.com/pandas-dev/pandas/issues/57587
true
null
null
natmokval
4
This bug has not been reported and exists on the latest version of pandas. **Reproducible Examples:** if `freq="h"` ``` from pandas import * import numpy as np frqncy = 'h' idx = period_range("01/01/2000", freq=frqncy, periods=4) df = DataFrame( np.array([0, 1, 0, 1]), index=idx, columns=["A"], ) res = df.plot() print(res.freq) print(df) ``` output: <img width="647" alt="output_h" src="https://github.com/pandas-dev/pandas/assets/91160475/3b268767-ae06-47f0-bab9-82d83c934f92"> But if `freq="60min"` ``` frqncy = '60min' idx = period_range("01/01/2000", freq=frqncy, periods=4) df = DataFrame( np.array([0, 1, 0, 1]), index=idx, columns=["A"], ) res = df.plot() print(res.freq) print(df) ``` the result of plotting is different <img width="623" alt="output_60min" src="https://github.com/pandas-dev/pandas/assets/91160475/ff4d44c3-2920-4238-bc8c-431f8489b460"> **Expected Behavior:** I think for both `freq="h"` and `freq="60min"` plotting should give the same result. The correct behavior should be that what is shown for `freq="h"`.
[ "Bug", "Visualization" ]
0
0
0
0
0
0
0
0
[ "take", "take", "Hi I am new to contributing, and I was wondering how you test your changes and see the visualizations when you do print(df). Right now, I am running python in the terminal, which i'm sure is not the optimal way, and I can only see \r\n2000-01-01 00:00 0\r\n2000-01-01 01:00 1\r\n2000-01-01 02:00 0\r\n2000-01-01 03:00 1\r\nand not the graph when running print(df)", "I believe the plots display automatically if you are using an interactive environment such as Jupyter notebook.\r\nOtherwise you can `import matplotlib.pyplot as plt` and then run `plt.show()` after you have plotted the DataFrame." ]
2,151,258,399
57,586
DOC-#57585: Add `Use Modin` section on `Scaling to large datasets` page
closed
2024-02-23T14:55:27
2024-03-07T17:17:43
2024-03-07T17:17:03
https://github.com/pandas-dev/pandas/pull/57586
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57586
https://github.com/pandas-dev/pandas/pull/57586
YarShev
16
- [x] closes #57585 (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
[ "pre-commit.ci autofix", "@rhshadrach, could you shed some light on why `Doc Build` is failing and what we should do to fix it?", "> @rhshadrach, could you shed some light on why `Doc Build` is failing and what we should do to fix it?\r\n\r\nL474, documentation is spelled incorrectly.", "> > @rhshadrach, could you shed some light on why `Doc Build` is failing and what we should do to fix it?\r\n> \r\n> L474, documentation is spelled incorrectly.\r\n\r\nOh, I see, thanks! FIxed.", "I see the Dask section was added 5 years ago, where there were probably no other alternatives. I think it's surely valuable for users to know about other tools to distribute work with a pandas API, but I don't think our user guide is the place to have and have to maintain a short tutorial of Dask. Modin, PySpark/Koalas and any other system that provides a distributed pandas-like API.\r\n\r\nWhat do you think if you have in each project documentation a page for pandas users that we can simply link here? @phofl @YarShev @HyukjinKwon", "> I see the Dask section was added 5 years ago, where there were probably no other alternatives. I think it's surely valuable for users to know about other tools to distribute work with a pandas API, but I don't think our user guide is the place to have and have to maintain a short tutorial of Dask. Modin, PySpark/Koalas and any other system that provides a distributed pandas-like API.\r\n> \r\n> What do you think if you have in each project documentation a page for pandas users that we can simply link here? @phofl @YarShev @HyukjinKwon\r\n\r\nWhile other projects can have a documentation page about their tool and pandas as to which library to use and when, I think mentioning other alternatives to pandas in pandas documentation itself is valuable to users since pandas is much more popular than the alternatives, and many more people will be able to see concrete options for efficient data processing.", "I don't disagree with you, and I think it's valuable for users to know the other packages in the ecosystem to scale what pandas can't handle.\r\n\r\nMy point is that in my opinion the pandas codebase is not where so much information from Dask or Modin should exist. I think we should have a paragraph so users know about the tools and what to expect about them, and all the details could be in a landing page for pandas users that you maintain in your docs, keep updated, and that we simply have a link here next to the summary of what each tool does.\r\n\r\nJust my personal opinion, but this should be as good for the users, but easier to maintain and keep updated.", "I tried to make the changes as concise as possible giving some pros and cons of Modin and when it should be used. I don't see anything in the changes that could be hard to maintain in future. If you have any improvements we could introduce in the paragraph, please let me know. It would be also great to hear opinions from other reviewers. cc @rhshadrach, @jbrockmendel ", "Building on what @datapythonista said - I don't see much advantage in having the documentation as it is in this PR vs just the intro paragraph ending with a line like `See more information in [modin's documentation](https://modin.readthedocs.io/en/stable/getting_started/quickstart.html#example-instant-scalability-with-no-extra-effort).` (or a better landing spot if there is one).\r\n\r\n> I don't see anything in the changes that could be hard to maintain in future.\r\n\r\nChanges to any of the third party packages currently listed would necessitate a change to the pandas documentation and is therefore quite likely to go stale. In addition each new tool that comes along we have to review another PR. It is all around less maintenance for us to have a summary paragraph and a link to the projects documentation where they compare to pandas.\r\n\r\nWhat is the disadvantage by having a link rather than the documentation live in pandas itself?", "@datapythonista what about pandas here points out the tutorial of individual project?\r\n\r\nBasically I support:\r\n\r\n> he intro paragraph ending with a line like See more information in [modin's documentation](https://modin.readthedocs.io/en/stable/getting_started/quickstart.html#example-instant-scalability-with-no-extra-effort). (or a better landing spot if there is one).\r\n\r\nWe won't have to duplicate the tutorials in pandas page, and individual project page.\r\n\r\nApache Spark is sort of doing in the same way: https://spark.apache.org/third-party-projects.html\r\n\r\nFWIW, Koalas has been migrated to PySpark as pandas API on Spark component so I have to update it in any event.", "> @datapythonista what about pandas here points out the tutorial of individual project?\r\n\r\nSounds great. My idea is that users reaching our page about scaling should know about the relevant options, but without pandas having lots of details in our docs when we can simply link to each projects docs. The exact page you link to I don't know, maybe a dedicated landing page for users coming from pandas, maybe the home of the Koalas documentation, no strong preference from my side.\r\n\r\nAlso worth mentioning that we already do it in the Ecosystem page in our website. Maybe for now I can just copy what it's there in a separate PR, and you all can review it or follow up with any change if needed. What do you think?", "@datapythonista, @HyukjinKwon, @rhshadrach, all your thoughts make sense to me now. We should probably put the detailed information about Modin and its joint usage with pandas in a single flow to Modin's documentation. I left three small paragraphs about Modin in this PR. How does it look like to you now?", "Ready for the next round of review. Hope it is fine now 😄 ", "@datapythonista, @HyukjinKwon, just a friendly reminder for review.", "@datapythonista, sounds good! Could you please tag me in the future PRs where you would reduce the Dask section and and PySpark/Koalas? I would like Modin to be in line with those libraries sections.", "Thanks @YarShev. Agreed that eventually this should just link to the ecosystem docs, but this is good as is. " ]
2,151,246,499
57,585
DOC: Add `Use Modin` section on `Scaling to large datasets` page
closed
2024-02-23T14:48:45
2024-03-07T17:17:04
2024-03-07T17:17:04
https://github.com/pandas-dev/pandas/issues/57585
true
null
null
YarShev
0
### 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/user_guide/scale.html ### Documentation problem While there are different libraries to scale large datasets, the only option shown on `scale.rst` page is Dask. It could be useful and valuable for users to get more options out of the page. One of the options could be Modin, which has a drop-in replacement API for pandas. It would be nice to show how Modin can speed up pandas operations, as well as to be used along with pandas in a single flow to get ultimate performance and reduce users's waiting time. ### Suggested fix for documentation Add a section about Modin.
[ "Docs" ]
0
0
0
0
0
0
0
0
[]
2,151,206,395
57,584
ENH: pd.series.sample when n > len
closed
2024-02-23T14:28:01
2024-05-19T18:32:37
2024-05-19T18:32:37
https://github.com/pandas-dev/pandas/issues/57584
true
null
null
marctorsoc
3
### Feature Type - [X] Adding new functionality to pandas - [X] Changing existing functionality in pandas - [ ] Removing existing functionality in pandas ### Problem Description Oftentimes, I have some code that samples from a df / series, as in ``` df.sample(sample_size, random_state=88) ``` and given new data, `sample_size > len(df)`, getting ``` ...Cannot take a larger sample than population... ``` I'd like a way to specify that if `sample_size > len(df)`, I just want all elements back. This is already the case with `.head()`. So I don't really understand why the behaviour is not the same here. ### Feature Description I can see two possible solutions 1. As in [here](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.head.html), "If n is larger than the number of rows, this function returns all rows." 2. If keping back-compatibility is a must, then adding a parameter `errors`, with possible values `ignore` or `raise` (default being `raise`, again to keep back-compatibility). I'd lean towards (1), but I'd be content with (2) ### Alternative Solutions I proposed two solutions. Of course, one can always add a line ``` sample_size = min(len(df), sample_size) ``` before the call, but I honestly think pandas should provide support for this common case + being consistent with other methods e.g. `head`. ### Additional Context Happy to contribute with this feature, but first checking here. Just making sure owners would consider it, and nobody is working on this atm.
[ "Enhancement", "Error Reporting", "Series", "Closing Candidate" ]
0
0
0
0
0
0
0
0
[ "IIRC the error comes from numpy.\r\n\r\nThis is what I get\r\n```\r\n File \"/Users/thomasli/pandas/pandas/core/sample.py\", line 153, in sample\r\n return random_state.choice(obj_len, size=size, replace=replace, p=weights).astype(\r\n File \"numpy/random/mtrand.pyx\", line 1001, in numpy.random.mtrand.RandomState.choice\r\nValueError: Cannot take a larger sample than population when 'replace=False\r\n```\r\n\r\nIn that case, in my opinion, I think it's probably best for you to add an if check in your code before the call to sample to restrict the sample size to the length of the dataframe.", "yeah, for the cases of production code, of course I can add an if. But when exploring on a notebook with constructions like this (imagine this is not static code, but iterating with many filters on it):\r\n```\r\n(\r\n df\r\n .loc[lambda df: df.price.gt(10)]\r\n .loc[lambda df: df.date.lt(\"2023-04\")\r\n .sample(10)\r\n)\r\n```\r\n\r\nHere you cannot do an if before because there's no before. I happen to do this very very often. I guess one solution would be ok, create a pipe and do\r\n```\r\n(\r\n df\r\n .loc[lambda df: df.price.gt(10)]\r\n .loc[lambda df: df.date.lt(\"2023-04\")\r\n .pipe(sample_pipe, n=10)\r\n)\r\n```\r\ncontaining the if... but I continue thinking that pandas should support my use case 🤷‍♂️ ", "Yeah especially since this is an error from numpy, I don't think it's appropriate for pandas to work around this so closing" ]
2,151,193,409
57,583
Backport PR #57582 on branch 2.2.x (DOC: Add contributors for 2.2.1)
closed
2024-02-23T14:21:06
2024-02-23T14:48:32
2024-02-23T14:48:32
https://github.com/pandas-dev/pandas/pull/57583
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57583
https://github.com/pandas-dev/pandas/pull/57583
meeseeksmachine
0
Backport PR #57582: DOC: Add contributors for 2.2.1
[ "Docs" ]
0
0
0
0
0
0
0
0
[]
2,151,132,592
57,582
DOC: Add contributors for 2.2.1
closed
2024-02-23T13:48:36
2024-02-23T14:20:57
2024-02-23T14:20:56
https://github.com/pandas-dev/pandas/pull/57582
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57582
https://github.com/pandas-dev/pandas/pull/57582
lithomas1
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.
[ "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/57582/" ]
2,150,555,493
57,581
Updating timeseries.offset_aliases links to use :ref: format
closed
2024-02-23T07:47:20
2024-02-23T17:04:21
2024-02-23T09:55:27
https://github.com/pandas-dev/pandas/pull/57581
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57581
https://github.com/pandas-dev/pandas/pull/57581
jordan-d-murphy
4
During code review on https://github.com/pandas-dev/pandas/pull/57562 it was suggested to update the links from this format `this link <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`__. to this format :ref:`this link<timeseries.offset_aliases>` I found several places where this same link was using this old format, so opened this PR to update them all for consistency. - [x] xref https://github.com/pandas-dev/pandas/pull/57562 - [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature - [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit). - [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions. - [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "@mroeschke can you take a look at this PR? based off the suggestion in https://github.com/pandas-dev/pandas/pull/57562", "pre-commit.ci autofix\r\n\r\n", "/preview", "Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57581/" ]
2,150,519,906
57,580
DOC: fixing GL08 errors for pandas.IntervalIndex.left, pandas.IntervalIndex.mid and pandas.IntervalIndex.length
closed
2024-02-23T07:28:03
2024-04-23T18:57:05
2024-04-23T18:57:05
https://github.com/pandas-dev/pandas/pull/57580
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57580
https://github.com/pandas-dev/pandas/pull/57580
j36426052
7
All GL08 Errors resolved in the following cases: scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.IntervalIndex.left scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.IntervalIndex.mid scripts/validate_docstrings.py --format=actions --errors=GL08 pandas.IntervalIndex.length xref #57443
[ "Docs" ]
0
0
0
0
0
0
0
0
[ "I want to know that what should I do next ? I am not sure what should I fix the error, because some of it I'm not really understand. Or should I just skip it?", "pre-commit.ci autofix", "@datapythonista just FYI there's an effort to minimize/remove docstring reuse (https://github.com/pandas-dev/pandas/pull/57683, https://github.com/pandas-dev/pandas/issues/57578) to minimize complexity of the docstring reuse mechanisms", "@j36426052 do you want to continue working in this PR? Besides addressing the comments you'll have to resolve the conflicts.", "Sorry that I'm not really sure what part I need to fix. The comment part, should I reuse some comment to let it's structure more complete. I'm not sure how to minimize/remove docstring. \r\n\r\nAlso the comflict in Numpy Dev, it show \"test-data.xml not found\", but I don't see some document talk about this.\r\n\r\nOr should I just skip the above I mention. Maybe you mean other comflict?", "As mroeschke said, there's no need to worry about reusing docstrings as they are trying to minimize docstring reuse.\r\nFocus on applying the 3 suggested \"general comments\" first.", "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,150,309,111
57,579
Backport PR #57576 on branch 2.2.x (DOC: Add release date for 2.2.1)
closed
2024-02-23T03:34:03
2024-02-23T04:47:35
2024-02-23T04:47:35
https://github.com/pandas-dev/pandas/pull/57579
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57579
https://github.com/pandas-dev/pandas/pull/57579
meeseeksmachine
0
Backport PR #57576: DOC: Add release date for 2.2.1
[ "Docs" ]
0
0
0
0
0
0
0
0
[]
2,150,305,047
57,578
CI: Docstring validation is slow
open
2024-02-23T03:28:19
2024-03-18T00:35:37
null
https://github.com/pandas-dev/pandas/issues/57578
true
null
null
lithomas1
8
It takes around 22 minutes, for some reason.
[ "CI" ]
0
0
0
0
0
0
0
0
[ "yeah it needs to generate all these docstrings, write them to temporary files, run validation against them...\r\n\r\ntbh I think we should rip all the docstring sharing logic, just have plain old docstrings without substitutions, and let ruff do all the linting and validation in a matter of seconds. this shouldn't be done manually though, maybe I should see if it's automatable\r\n\r\ndoctests can be validated with pytest --doctest-modules", "> tbh I think we should rip all the docstring sharing logic, just have plain old docstrings without substitutions,\r\n\r\nBig +1", "cool - no idea how difficult this actually is but I'll give it a go next week and see", "I started this here: https://github.com/pandas-dev/pandas/pull/57683\r\n\r\nI have a little script to do this, which seems to working well enough. Before I go too far, just checking people are OK with it\r\n\r\nPros of keeping docstring substitutions:\r\n- shorter docstrings within the code\r\n- helps dedupe some parameter definitions\r\n\r\nPros of removing docstring substitions:\r\n- docstrings become simple and easy-to-review\r\n- drastically faster docstring checking thanks to ruff\r\n- blazingly fast docstring formatting becomes possible\r\n- unblocks using `darglint` rules (which may make their way into ruff!) https://github.com/astral-sh/ruff/issues/458, and any other fast docstring rules in ruff (they already have pydocstyle ones)\r\n\r\nI don't think ruff replaces _all_ of the `validate_docstrings` script, but that script can be used with or without docstring substitutions. But removing docstring substitutions at least means we can start removing things from `validate_docstrings` which are covered by ruff and cut down on CI like this", "> yeah it needs to generate all these docstrings, write them to temporary files, run validation against them...\r\n\r\nI get we have a lot of docstrings but I am surprised that this would take 22 minutes.\r\n\r\nNot a hill I'd want to die on but I do think the shared docstrings serve a good purpose in keeping things consistent", "Wasn't aware of this issue and wrote #57826 after I introduced a docstring error in my first PR and got annoyed at the speed of the docstring checks. It reduces the runtime of the `check_code.sh docstrings` down to 2-3 minutes again.\r\n\r\nI also have another PR ready to go once #57826 is merged. That second PR brings the validation down to about 10 seconds. Main issue was the way the temp files were created and how pep8 was called via the shell.\r\n\r\nSo maybe with a 10 second runtime it's not necessary to do any functionality changes to the docstring validation and sharing in the end?", "> So maybe with a 10 second runtime it's not necessary to do any functionality changes to the docstring validation and sharing in the end?\r\n\r\nI think the docstring sharing is still worth removing to:\r\n\r\n1. Make it easier for new contributors to work on docstrings due to less complexity\r\n2. Allow `ruff` to take over docstring formatting and validation", "I'm happy to move towards removing or reducing the docstring sharing. But based on my experience getting fully rid of it may take years. If we want to proactively work on duplicating now reused docstrings, I'd start by the ones with higher complexity and see how that goes, before opening issues to remove all them." ]
2,150,281,657
57,577
BUG: Dataframe row not being updated after value update within iterrows
closed
2024-02-23T02:55:49
2024-02-23T17:19:26
2024-02-23T17:19:25
https://github.com/pandas-dev/pandas/issues/57577
true
null
null
Aswin22-tech
1
### Pandas version checks - [X] I have checked that this issue has not already been reported. - [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas. - [X] I have confirmed this bug exists on the [main branch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-development-version-of-pandas) of pandas. ### Reproducible Example ```python # Import pandas library import pandas as pd # initialize list of lists data = [['tom', 10], ['nick', 15], ['juli', 14]] # Create the pandas DataFrame df = pd.DataFrame(data, columns=['Name', 'Age']) for index,row in df.iterrows(): df.loc[index,'Name'] = 'newer name' print(row['Name']) ``` ### Issue Description Within iterrows, when you are updating the value of a column using df.loc[index,'column name'], isn't the update supposed to happen immediately? I have read somewhere that iterrows uses a copy of dataframe and not the actual dataframe. But I feel it is more logical to have the update done immediately. In the example provided above, print statement prints the old values in name column and not "newer name", which definitely looks like an issue to me. At the same time, if I use the same .loc command, it is showing new value, which is weird. I have attached the screenshots. <img width="430" alt="pandas_issue_1" src="https://github.com/pandas-dev/pandas/assets/80024139/6dbfac9d-cf93-4627-963a-bb2f7dfc00cb"> <img width="389" alt="pandas_issue_2" src="https://github.com/pandas-dev/pandas/assets/80024139/078468b7-9d1a-4e85-acdf-e10fe75c82d3"> ### Expected Behavior As mentioned above, expected behavior would be to have the values updated immediately ### Installed Versions <details> I am getting error when I call this function. Attached the screenshot. <img width="823" alt="pandas_issue_3" src="https://github.com/pandas-dev/pandas/assets/80024139/aa032c98-32a9-4f9c-b36d-e5c1232c0e33"> </details>
[ "Bug", "Needs Triage" ]
0
0
0
0
0
0
0
0
[ "It's important to note that it's bad practice to modify the object you're iterating over.\r\n\r\nSecond, `row` is a distinct object from `df` so the assignment is only modifying `df`. Since this is the expected behavior closing." ]
2,150,278,825
57,576
DOC: Add release date for 2.2.1
closed
2024-02-23T02:51:14
2024-02-23T03:33:51
2024-02-23T03:33:51
https://github.com/pandas-dev/pandas/pull/57576
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57576
https://github.com/pandas-dev/pandas/pull/57576
lithomas1
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.
[ "Docs" ]
0
0
0
0
0
0
0
0
[]
2,150,272,623
57,575
CLN: Assorted khash-python cleanups
closed
2024-02-23T02:41:25
2024-02-23T17:20:54
2024-02-23T17:09:33
https://github.com/pandas-dev/pandas/pull/57575
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57575
https://github.com/pandas-dev/pandas/pull/57575
WillAyd
1
null
[ "Internals" ]
0
0
0
0
0
0
0
0
[ "Thanks @WillAyd " ]
2,150,242,882
57,574
CLN: Clean up unnecessary templating in hashtable
closed
2024-02-23T02:00:18
2024-02-23T02:07:16
2024-02-23T02:07:15
https://github.com/pandas-dev/pandas/pull/57574
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57574
https://github.com/pandas-dev/pandas/pull/57574
WillAyd
1
khash already provides a macro for these which takes the type as the first argument - no need to import function names the way we do
[]
0
0
0
0
0
0
0
0
[ "Hmm nevermind. Looks like we have other code paths for complex - not worth the effort" ]
2,150,138,616
57,573
Backport PR #57314 on branch 2.2.x (BUG: Fix near-minimum timestamp handling)
closed
2024-02-22T23:53:48
2024-02-23T00:38:10
2024-02-23T00:38:10
https://github.com/pandas-dev/pandas/pull/57573
true
https://api.github.com/repos/pandas-dev/pandas/pulls/57573
https://github.com/pandas-dev/pandas/pull/57573
meeseeksmachine
0
Backport PR #57314: BUG: Fix near-minimum timestamp handling
[ "Regression", "Timestamp" ]
0
0
0
0
0
0
0
0
[]