Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Ignore warning for duplicate columns in to_dict when orient='tight' #58335

Merged
merged 10 commits into from Apr 24, 2024

Conversation

luke396
Copy link
Contributor

@luke396 luke396 commented Apr 20, 2024

Copy link
Contributor

@Aloqeely Aloqeely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

doc/source/whatsnew/v3.0.0.rst Outdated Show resolved Hide resolved
pandas/tests/frame/methods/test_to_dict.py Outdated Show resolved Hide resolved
luke396 and others added 2 commits April 21, 2024 08:51
Co-authored-by: Abdulaziz Aloqeely <52792999+Aloqeely@users.noreply.github.com>
@luke396
Copy link
Contributor Author

luke396 commented Apr 21, 2024

Thank you for replying so quickly, all the comments are fixed.

@mroeschke mroeschke added Output-Formatting __repr__ of pandas objects, to_string Warnings Warnings that appear or should be added to pandas labels Apr 22, 2024
@luke396 luke396 requested a review from mroeschke April 23, 2024 10:56
def test_to_dict_tight_no_warning_with_duplicate_column(self):
# GH#58281
df = DataFrame([[1, 2], [3, 4], [5, 6]], columns=["A", "A"])
assert df.to_dict(orient="tight") == {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you still assert that df.to_dict(orient="tight") doesn't raise a warning?

Also can you structure like

result = 
expected = 
assert result == expected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this time? Am I understanding correctly?

@luke396 luke396 requested a review from mroeschke April 24, 2024 09:26
@mroeschke mroeschke added this to the 3.0 milestone Apr 24, 2024
@mroeschke mroeschke merged commit 41014db into pandas-dev:main Apr 24, 2024
43 of 46 checks passed
@mroeschke
Copy link
Member

Thanks @luke396

@luke396 luke396 deleted the gh#58281 branch April 25, 2024 01:31
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…ight' (pandas-dev#58335)

* Ignore warning for duplicate columns in to_dict when orient='tight'

* Add whatsnew

* Update doc/source/whatsnew/v3.0.0.rst

Co-authored-by: Abdulaziz Aloqeely <52792999+Aloqeely@users.noreply.github.com>

* Update whatsnew and redefine duplicate columns

* Use assert instead

* assert not raise and equal

---------

Co-authored-by: Abdulaziz Aloqeely <52792999+Aloqeely@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: df.to_dict(orient='tight') raises UserWarning incorrectly for duplicate columns
3 participants