Skip to content

Conversation

AnushaUKumar
Copy link

What does this PR do?

Fixes confusing behavior when .assign() is used with non-string keys like tuples. Python raises a generic TypeError: keywords must be strings, which confuses users.

This PR adds a more helpful message:

assign() only supports string column names. Use df[('C', 'one')] = ... to assign non-string column names like tuples.

Why?

This improves the developer experience and avoids unnecessary debugging time.

How was this fixed?

  • Added __kwargs_dict__ as a keyword-only argument for testing with tuple keys
  • Added validation in assign() for string-only keys
  • Updated existing test for compatibility
  • Added new test: test_assign_with_tuple_column_key_raises_typeerror

Test added

test_assign_with_tuple_column_key_raises_typeerror

meeseeksmachine and others added 30 commits August 12, 2023 21:55
…e_convert_objects) (#54512)

Backport PR #54498: Speed up string inference in maybe_convert_objects

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…ng.corr) (#54513)

Backport PR #54504: Move Unit Tests for groupby.rolling.corr

Co-authored-by: omar-elbaz <114315316+omar-elbaz@users.noreply.github.com>
…A dtypes) (#54514)

Backport PR #54509: PERF: Dataframe reductions with EA dtypes

Co-authored-by: Luke Manley <lukemanley@gmail.com>
Backport PR #54517: Run CI on 2.1.x

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…) workarounds for pyarrow versions >= 11.0) (#54524)

Backport PR #54515: ENH: ArrowExtensionArray(duration) workarounds for pyarrow versions >= 11.0

Co-authored-by: Luke Manley <lukemanley@gmail.com>
Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…types) (#54528)

Backport PR #54341: PERF: axis=1 reductions with EA dtypes

Co-authored-by: Luke Manley <lukemanley@gmail.com>
… variable) (#54538)

Backport PR #54536: REF: Move checks to object into a variable

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…red with new string dtype) (#54539)

Backport PR #54534: REF: Move methods that can be shared with new string dtype

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
… for string tests) (#54559)

Backport PR #54537: REF: Refactor using_pyarrow check for string tests

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
Backport PR #54525: BLD: Fix version script

Co-authored-by: Thomas Li <47963215+lithomas1@users.noreply.github.com>
…1 to 2.15.0) (#54558)

Backport PR #54541: Bump pypa/cibuildwheel from 2.14.1 to 2.15.0

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…s list) (#54562)

Backport PR #54493: DOC: updated required dependencies list

Co-authored-by: Rajat Subhra Mukherjee <raromukherjee@gmail.com>
… namespace refactor Part 3) (#54583)

Backport PR #54579: ENH: Reflect changes from `numpy` namespace refactor Part 3

Co-authored-by: Mateusz Sokół <8431159+mtsokol@users.noreply.github.com>
…54588)

Backport PR #54545: DOC: whatsnew 2.1.0 refinements

Co-authored-by: Richard Shadrach <45562402+rhshadrach@users.noreply.github.com>
…rage checks with variable) (#54594)

Backport PR #54535: REF: Replace "pyarrow" string storage checks with variable

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…pport for arrow dtypes) (#54603)

Backport PR #54574: ENH: add cummax/cummin/cumprod support for arrow dtypes

Co-authored-by: Luke Manley <lukemanley@gmail.com>
… the README) (#54619)

Backport PR #54615: DOC: Update build instructions in the README

Co-authored-by: Thomas Li <47963215+lithomas1@users.noreply.github.com>
#54614)

Backport PR #54587: CI: Enable MacOS Python Dev tests

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
…lue) (#54658)

Backport PR #54586: REF: Refactor conversion of na value

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…tli as optional dependencies (no longer used)) (#54637)

Backport PR #54633: DEP: remove python-snappy and brotli as optional dependencies (no longer used)

Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
…#54669)

Backport PR #54641: BUG: getitem indexing wrong axis

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…y strings with arrow string option) (#54672)

Backport PR #54496: Fix inference for fixed with numpy strings with arrow string option

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…w duration conversion) (#54688)

Backport PR #54678: COMPAT: Workaround invalid PyArrow duration conversion

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
…entation for merge) (#54689)

Backport PR #54510: Speed up StringDtype arrow implementation for merge

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…in ArrowExtensionArray) (#54691)

Backport PR #54685: ENH: support integer bitwise ops in ArrowExtensionArray

Co-authored-by: Luke Manley <lukemanley@gmail.com>
…boolean arrow dtype with missing values) (#54692)

Backport PR #54670: BUG: drop_duplicates raising for boolean arrow dtype with missing values

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
…loat, timedelta64 dtypes) (#54693)

Backport PR #54566: ENH: support Index.any/all with float, timedelta64 dtypes

Co-authored-by: jbrockmendel <jbrockmendel@gmail.com>
…calls) (#54697)

Backport PR #54694: MAINT: Remove `np.in1d` function calls

Co-authored-by: Mateusz Sokół <8431159+mtsokol@users.noreply.github.com>
…ne series) (#54698)

Backport PR #54625: BUG: Fix error in printing timezone series

Co-authored-by: Adrian D'Alessandro <a.dalessandro@imperial.ac.uk>
…dtypes) (#54700)

Backport PR #54508: PERF: DataFrame.iloc[int] for EA dtypes

Co-authored-by: Luke Manley <lukemanley@gmail.com>
meeseeksmachine and others added 24 commits October 25, 2023 16:22
…ing numba raising TypeError when the…) (#55686)

Backport PR #55586: REGR: Groupby methods not supporting numba raising TypeError when the…

Co-authored-by: Thomas Li <47963215+lithomas1@users.noreply.github.com>
… values when ts index is not nano seconds) (#55697)

Backport PR #55173: BUG: .rolling() returns incorrect values when ts index is not nano seconds

Co-authored-by: Hadi Abdi Khojasteh <hadiabdikhojasteh@gmail.com>
#55701)

Backport PR #55527: BUG fix deprecation of `limit` and `fill_method` in `pct_change`

Co-authored-by: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com>
… with sqlite type detection) (#55702)

REGR: fix roundtripping datetimes with sqlite type detection (#55690)

(cherry picked from commit aeb3644)
…gr to pass manager object to constructor) (#55704)

Backport PR #54922: REGR: Restore _constructor_from_mgr to pass manager object to constructor
…n of large strings (avoid overflow from concat)) (#55706)

Backport PR #55691: REGR: fix read_parquet with column of large strings (avoid overflow from concat)

Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
)

Backport PR #55722: DOC: Add whatsnew for 2.1.3

Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
… inference for NEP 50) (#55716)

Backport PR #55707: REF: Avoid np.can_cast for scalar inference for NEP 50

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
…55749)

Backport PR #55747: DOC: Fix release date for 2.1.2

Co-authored-by: Thomas Li <47963215+lithomas1@users.noreply.github.com>
…utc) (#55796)

Backport PR #55726: fix segfault with tz_localize_to_utc

Co-authored-by: William Ayd <will_ayd@innobi.io>
…lt for Numpy 2.0) (#55851)

Backport PR #55817: COMPAT: Numpy int64 Windows default for Numpy 2.0

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
…ypeError) (#55819)

* Backport PR #55473: TST: sort index with sliced MultiIndex

* BUG: DatetimeIndex.diff raising TypeError (#55761)

* BUG: DatetimeIndex.diff raising TypeError

* add test and whatsnew

* typing

* use Index

(cherry picked from commit f04da3c)

* fix whatsnew
* TST: Make read_csv tests pyarrow 13 compatable on 2.1.x

* Skip on windows for ARROW_TIMEZONE_DATABASE
…er has the wrong dtype / from_dataframe incorrect ) (#55863)

Backport PR #55227: BUG: Interchange object data buffer has the wrong dtype / from_dataframe incorrect

Co-authored-by: Marco Edward Gorelli <marcogorelli@protonmail.com>
Co-authored-by: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com>
…umPy's broadcasting) (#55896)

Backport PR #55427: DOC: Remove outdated docs about NumPy's broadcasting

Co-authored-by: cobalt <61329810+RedGuy12@users.noreply.github.com>
…uctor_from_mgr for simple subclasses) (#55892)

Backport PR #55764: REGR: fix return class in _constructor_from_mgr for simple subclasses

Co-authored-by: Isaac Virshup <ivirshup@gmail.com>
…ype autoload (#55900)

Parquet/Feather IO: disable PyExtensionType autoload (#55894)

* Parquet/Feather IO: disable PyExtensionType autoload

* don't install hotfix for pyarrow >= 14.0.1

* move patching to extension type definitions

* expand error message

* fix compat for pyarrow not installed

* add whatsnew

(cherry picked from commit 851fea0)
…55913)

Backport PR #55907: DOC: Add release date for 2.1.3

Co-authored-by: Thomas Li <47963215+lithomas1@users.noreply.github.com>
…NumPy's broadcasting to literal code block) (#55912)

Backport PR #55911: DOC: convert outdated example of NumPy's broadcasting to literal code block

Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
@mroeschke
Copy link
Member

Thanks for the PR, but it appears there a lot of changes in unrelated files. Going to close this PR, but ensure that pull requests are made from the latest commit on main

@mroeschke mroeschke closed this Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants