Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/source/whatsnew/v0.18.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,9 @@ Bug Fixes
- Bug in ``pd.rolling_median`` where memory allocation failed even with sufficient memory (:issue:`11696`)

- Bug in ``df.replace`` while replacing value in mixed dtype ``Dataframe`` (:issue:`11698`)





- Bug in ``DataFrame.info`` when duplicated column names exist (:issue:`11761`)
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,7 @@ def _verbose_repr():

dtypes = self.dtypes
for i, col in enumerate(self.columns):
dtype = dtypes[col]
dtype = dtypes.iloc[i]
col = com.pprint_thing(col)

count = ""
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7559,6 +7559,18 @@ def test_info_duplicate_columns(self):
columns=['a', 'a', 'b', 'b'])
frame.info(buf=io)

def test_info_duplicate_columns_shows_correct_dtypes(self):
# GH11761
io = StringIO()

frame = DataFrame([[1, 2.0]],
columns=['a', 'a'])
frame.info(buf=io)
io.seek(0)
lines = io.readlines()
self.assertEqual('a 1 non-null int64\n', lines[3])
self.assertEqual('a 1 non-null float64\n', lines[4])

def test_info_shows_column_dtypes(self):
dtypes = ['int64', 'float64', 'datetime64[ns]', 'timedelta64[ns]',
'complex128', 'object', 'bool']
Expand Down