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: Inconsistency in converting Series to Dataframe when columns specified #10006

Closed
artemyk opened this issue Apr 28, 2015 · 9 comments
Closed
Labels
Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions

Comments

@artemyk
Copy link
Contributor

artemyk commented Apr 28, 2015

The dtypes don't match:

In [16]: pd.DataFrame(pd.Series([], dtype="int64"), columns=["D"]).dtypes
Out[16]: 
D    object
dtype: object

In [17]: pd.DataFrame(pd.Series([], dtype="int64")).dtypes
Out[17]: 
0    int64
dtype: object

This came up in #9983 .

When this is fixed, the check_dtype flag should also be removed in TestDataFrame.test_mode in pandas/tests/test_frame.py .

@TomAugspurger
Copy link
Contributor

Maybe related: #10006

Haven't looked closely but they sound similar. I can't remember where I was at on that PR

@artemyk
Copy link
Contributor Author

artemyk commented Apr 28, 2015

@TomAugspurger I think you meant a different PR ;-)

@TomAugspurger
Copy link
Contributor

😆 #9237 is the one

@artemyk
Copy link
Contributor Author

artemyk commented Apr 28, 2015

#9237 looks relevant indeed. Perhaps this case could also be tested/fixed in there?

@TomAugspurger
Copy link
Contributor

Probably. Does your PR in #9983 depend on this being fixed?

@artemyk
Copy link
Contributor Author

artemyk commented Apr 28, 2015

I would say not. In #9983 we are adding an extra check_dtype=False in pandas/tests/test_frame.py to get around this issue, but that can be removed in the commit for #9237 . @jreback -- thoughts?

@jreback
Copy link
Contributor

jreback commented Apr 28, 2015

no this is independent

@jreback
Copy link
Contributor

jreback commented Apr 28, 2015

actually this is not a bug; #9237 maybe will address the 'issue'. But this is correct. Passing columns reindexes the frame; since the Series is is not named (well it actually is de-facto named 0), it is effectively removed, and thus the dtype is object which is correct.

Pls remove the comment in the original issue w.r.t. to this.

@jreback jreback closed this as completed Apr 28, 2015
@jreback
Copy link
Contributor

jreback commented Apr 28, 2015

sorry meant #9237

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Compat pandas objects compatability with Numpy or Python functions labels Apr 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

No branches or pull requests

3 participants