Skip to content

Commit

Permalink
ENH: warn user when invoking to_dict() on df with non-unique columns
Browse files Browse the repository at this point in the history
  • Loading branch information
y-p committed Nov 11, 2012
1 parent 4a5b75b commit bd45d39
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,10 @@ def to_dict(self, outtype='dict'):
-------
result : dict like {column -> {index -> value}}
"""
import warnings
if not self.columns.is_unique:
warnings.warn("DataFrame columns are not unique, some "
"columns will be omitted.",UserWarning)
if outtype.lower().startswith('d'):
return dict((k, v.to_dict()) for k, v in self.iteritems())
elif outtype.lower().startswith('l'):
Expand Down

0 comments on commit bd45d39

Please sign in to comment.