BUG: DataFrame.insert with allow_duplicates=True fails when already duplicates present · Issue #14291 · pandas-dev/pandas (original) (raw)

upon DataFrame.insert option allow_duplicates works, but only only once.
When i have 2 columns with same name, additon of third throws

ValueError: Wrong number of items passed 2, placement implies 1

Code Sample, a copy-pastable example if possible

a = pd.DataFrame()
a.insert(0, "qwe", [1,2,3,4], allow_duplicates=True)
a.insert(0, "qwe", [1,2,3,4], allow_duplicates=True)
a.insert(0, "qwe", [1,2,3,4], allow_duplicates=True)

Expected Output

zxc qwe qwe
0 1 1 1
1 2 2 2
2 3 3 3
3 4 4 4

output of pd.show_versions()

## INSTALLED VERSIONS

commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: ru_RU

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 25.1.6
Cython: 0.24.1
numpy: 1.11.1
scipy: 0.18.0
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.2
lxml: 3.6.4
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: 0.7.6.None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None
<\details>