Skip to content

Commit bd45d39

Browse files
author
y-p
committed
ENH: warn user when invoking to_dict() on df with non-unique columns
1 parent 4a5b75b commit bd45d39

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/frame.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,10 @@ def to_dict(self, outtype='dict'):
837837
-------
838838
result : dict like {column -> {index -> value}}
839839
"""
840+
import warnings
841+
if not self.columns.is_unique:
842+
warnings.warn("DataFrame columns are not unique, some "
843+
"columns will be omitted.",UserWarning)
840844
if outtype.lower().startswith('d'):
841845
return dict((k, v.to_dict()) for k, v in self.iteritems())
842846
elif outtype.lower().startswith('l'):

0 commit comments

Comments
 (0)