-
-
Notifications
You must be signed in to change notification settings - Fork 17.4k
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: Fix dtype inconsistency when appending to empty DataFrame #22703
Conversation
Hello @araraonline! Thanks for submitting the PR.
|
|
||
df = DataFrame() | ||
series = Series({'A': 1}, name='foobar', dtype='int64') | ||
assert df.append(series).dtypes['A'] == 'int64' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls construct the expected frame
and use assert_frame_equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just did it
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -775,6 +775,7 @@ Reshaping | |||
- Bug in :meth:`DataFrame.replace` raises ``RecursionError`` when replacing empty lists (:issue:`22083`) | |||
- Bug in :meth:`Series.replace` and meth:`DataFrame.replace` when dict is used as the ``to_replace`` value and one key in the dict is is another key's value, the results were inconsistent between using integer key and using string key (:issue:`20656`) | |||
- Bug in :meth:`DataFrame.drop_duplicates` for empty ``DataFrame`` which incorrectly raises an error (:issue:`20516`) | |||
- Bug in :meth:`DataFrame.append` would produce an inconsistent dtype when appending to empty DataFrame (:issue:`22621`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use double backticla around DataFrame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this too!
This is not passing some tests that I did't notice before. Gotta see what's wrong |
Got a question. The problem ended up having a scope slightly bigger than what was mentioned in the Issue #22621 Now I'm working on a branch that fixes the dtype inconsistency when appending an array to a dframe, whether this dframe is empty or not. Should I create a new PR? |
@araraonline no you can just update this one |
I'm currently working on rewriting the DataFrame.append function. When it is ready, the issue related here will be resolved |
git diff upstream/master -u -- "*.py" | flake8 --diff
edit: currently rewriting the DataFrame.append function