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: Fix dtype inconsistency when appending to empty DataFrame #22703

Closed

Conversation

lowerthansound
Copy link

@lowerthansound lowerthansound commented Sep 13, 2018

edit: currently rewriting the DataFrame.append function

@pep8speaks
Copy link

Hello @araraonline! Thanks for submitting the PR.


df = DataFrame()
series = Series({'A': 1}, name='foobar', dtype='int64')
assert df.append(series).dtypes['A'] == 'int64'
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

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

just did it

@@ -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`)
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

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

and this too!

@lowerthansound
Copy link
Author

This is not passing some tests that I did't notice before.

Gotta see what's wrong

@gfyoung gfyoung added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Dtype Conversions Unexpected or buggy dtype conversions labels Sep 14, 2018
@lowerthansound
Copy link
Author

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?

@jreback
Copy link
Contributor

jreback commented Sep 23, 2018

@araraonline no you can just update this one

@lowerthansound
Copy link
Author

I'm currently working on rewriting the DataFrame.append function. When it is ready, the issue related here will be resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dtype inconsistency when appending to empty dataframe
4 participants