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

This fix allows a DataFrame to retain key order from a dictionary #55696

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

paulreece
Copy link
Contributor

@paulreece paulreece commented Oct 26, 2023

This fix allows a DataFrame to retain key order from a dictionary with only one column instead of sorting them alphabetically.

Note: I had to change the order for the rename tests in test_rename.py but the order there seemed trivial. If I'm wrong in my assumption please let me know. I also had to change the index order of the control df in indexing/multiindex/test_setitem.py but again this seemed trivial/innocuous change in this circumstance.

@paulreece paulreece force-pushed the single_column_order_from_dict branch 4 times, most recently from 293d478 to f605da2 Compare October 27, 2023 14:41
@@ -327,7 +327,7 @@ Datetimelike
- Bug in addition or subtraction of :class:`BusinessDay` offset with ``offset`` attribute to non-nanosecond :class:`Index`, :class:`Series`, or :class:`DataFrame` column giving incorrect results (:issue:`55608`)
- Bug in addition or subtraction of :class:`DateOffset` objects with microsecond components to ``datetime64`` :class:`Index`, :class:`Series`, or :class:`DataFrame` columns with non-nanosecond resolution (:issue:`55595`)
- Bug in addition or subtraction of very large :class:`Tick` objects with :class:`Timestamp` or :class:`Timedelta` objects raising ``OverflowError`` instead of ``OutOfBoundsTimedelta`` (:issue:`55503`)
-
- Bug in creating a Dataframe using the from_dict method which would alphabetize the rows of the created DataFrame. (:issue:`55683`)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Bug in creating a Dataframe using the from_dict method which would alphabetize the rows of the created DataFrame. (:issue:`55683`)
- Bug in :meth:`Dataframe.from_dict` which would always sort the rows of the created :class:`DataFrame`. (:issue:`55683`)

@@ -53,10 +53,10 @@ def test_rename(self, float_frame):
# gets sorted alphabetical
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 remove this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just fixed both of these! Thanks for taking a look.

@mroeschke mroeschke added the DataFrame DataFrame data structure label Oct 27, 2023
@paulreece paulreece force-pushed the single_column_order_from_dict branch 2 times, most recently from 1f85072 to 9dc4a63 Compare October 27, 2023 20:34
@paulreece paulreece closed this Oct 27, 2023
@paulreece paulreece force-pushed the single_column_order_from_dict branch from 9dc4a63 to 074ab2f Compare October 27, 2023 20:36
…h only one column instead of sorting them alphabetically.
@paulreece
Copy link
Contributor Author

Not sure why this Closed.

@paulreece paulreece reopened this Oct 27, 2023
@mroeschke mroeschke added this to the 2.2 milestone Oct 30, 2023
@mroeschke mroeschke merged commit 73e085e into pandas-dev:main Oct 30, 2023
36 of 66 checks passed
@mroeschke
Copy link
Member

Thanks @paulreece

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataFrame DataFrame data structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Inconsistent Sorting using DataFrame.from_dict() method
2 participants