Code Sample, a copy-pastable example if possible
>>> import pandas
>>> df = pandas.read_csv('test.csv')
>>> df
A A.1 B
0 1 2 3
>>> df.columns
Index(['A', 'A.1', 'B'], dtype='object')
>>> for row in df.itertuples(index=False):
... print(row)
...
Pandas(A=1, _1=2, B=3)
Problem description
The row should show up as Pandas(A=1, A.1=2, B=3)
OR start supporting mangle_dupe_cols=False
to overwrite duplicate columns.
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.19.0
nose: None
pip: 9.0.1
setuptools: 30.3.0
Cython: None
numpy: 1.11.2
scipy: None
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: None
boto: 2.45.0
pandas_datareader: None
Comment From: jreback
this is indicated in the doc-string (read Notes). NamedTuples do not support these identifier.
In [1]: DataFrame.itertuples?
Signature: DataFrame.itertuples(self, index=True, name='Pandas')
Docstring:
Iterate over DataFrame rows as namedtuples, with index value as first
element of the tuple.
Parameters
----------
index : boolean, default True
If True, return the index as the first element of the tuple.
name : string, default "Pandas"
The name of the returned namedtuples or None to return regular
tuples.
Notes
-----
The column names will be renamed to positional names if they are
invalid Python identifiers, repeated, or start with an underscore.
With a large number of columns (>255), regular tuples are returned.
See also
--------
iterrows : Iterate over DataFrame rows as (index, Series) pairs.
iteritems : Iterate over (column name, Series) pairs.
Examples
--------
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [0.1, 0.2]},
index=['a', 'b'])
>>> df
col1 col2
a 1 0.1
b 2 0.2
>>> for row in df.itertuples():
... print(row)
...
Pandas(Index='a', col1=1, col2=0.10000000000000001)
Pandas(Index='b', col1=2, col2=0.20000000000000001)
File: ~/pandas/pandas/core/frame.py
Type: function