Skip to content

Commit 0c72d8b

Browse files
committed
BUG: fix DataFrame.info with non-unique columns close #1700
1 parent eb3c4e6 commit 0c72d8b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

RELEASE.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pandas 0.8.2
5050
- Fixed GroupBy bugs interacting with DatetimeIndex asof / map methods (#1677)
5151
- Handle factors with NAs in pandas.rpy (#1615)
5252
- Fix statsmodels import in pandas.stats.var (#1734)
53+
- Fix DataFrame repr/info summary with non-unique columns (#1700)
5354

5455
pandas 0.8.1
5556
============

pandas/core/frame.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,8 @@ def convert_objects(self):
13401340

13411341
def get_dtype_counts(self):
13421342
counts = {}
1343-
for _, series in self.iterkv():
1343+
for i in range(len(self.columns)):
1344+
series = self.icol(i)
13441345
# endianness can cause dtypes to look different
13451346
dtype_str = str(series.dtype)
13461347
if dtype_str in counts:

pandas/tests/test_frame.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3491,6 +3491,14 @@ def test_info(self):
34913491
frame.info(verbose=False)
34923492
sys.stdout = sys.__stdout__
34933493

3494+
def test_info_duplicate_columns(self):
3495+
io = StringIO()
3496+
3497+
# it works!
3498+
frame = DataFrame(np.random.randn(1500, 4),
3499+
columns=['a', 'a', 'b', 'b'])
3500+
frame.info(buf=io)
3501+
34943502
def test_dtypes(self):
34953503
self.mixed_frame['bool'] = self.mixed_frame['A'] > 0
34963504
result = self.mixed_frame.dtypes

0 commit comments

Comments
 (0)