-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: df fails when columns arg is a list containing dupes #2079
Milestone
Comments
ghost
mentioned this issue
Oct 17, 2012
Fixing this is quite an undertaking since there's a lot of existing constructor code that assumes unique column names. I'm on it; probably get it sorted out over next day or so |
Should this work? pd.DataFrame.from_items([('a',['foo']),('a',['bar'])],columns=['a','a'])
Out[6]:
a a
0 bar bar |
Also, forgive the nitpick, but since sdict is now abandoned, it would be good to rename the methods def _list_to_sdict(data, columns, coerce_float=False):
def _list_of_series_to_sdict(data, columns, coerce_float=False):
def _list_of_dict_to_sdict(data, columns, coerce_float=False): |
Yeah that should work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
5e6db32 is a failing test for this.
it looks like
_to_sdict
threads down to a call to_convert_object_array
which builds a dictkeyed on column names, so dupe columns get squashed and you end up with a mismatch
between the length of the
columns
arg todf.__init__
and the data._to_sdict is not used for ndarrays so this doesn't haoppen, I was able to reuse
_init_ndarray
for the case ofcolumns
being a flat list and have things work as expected.still, too much code touching this, better left to the core devs to decide how to handle this.
The text was updated successfully, but these errors were encountered: