Skip to content
Home » Solve “columns overlap but no suffix specified” in Pandas

Solve “columns overlap but no suffix specified” in Pandas

Surprisingly, the Pandas error “columns overlap but no suffix specified”, is one I ran into surprisingly late. Solving it is usually very straightforward. We’ll tackle it in this blog post.

First, let’s take a closer look at the error:

“ValueError: columns overlap but no suffix specified: Index([<list of columns>], dtype=’object’)”

When you run into this error, in all likelihood you are using the Pandas join method. What the error is telling you is that in the DataFrames you’re trying to join, there are some column names that exist in both DataFrames. Pandas is telling you to provide a suffix for the column names in both DataFrames, so you will be able to distinguish the difference in the joined DataFrame.

In the following code snippet, you can see that the columns ‘b’ and ‘c’ exist in both DataFrames and we don’t join on it. This will produce the error.

df1 = pd.DataFrame({'a': [1,0,2,3,4],'b': [0,0,0,0,0], 'c': [9,12,15,16,54]})
df1.set_index('a')
df2 = pd.DataFrame({'a': [1,0,2,3,4],'b': [5,0,3,1,0], 'c': [8,2,100,26,23]})
df2.set_index('a')
df1.join(df2, how = 'left')

Solving the error is easy. Simply provide a suffix.

df1.join(df2, how = 'left', lsuffix = '_left', rsuffix = '_right')

There is an alternative solution. Use the merge method. It will give priority to the columns of the DataFrame that you provided in the ‘how’ argument.

df1.merge(df2, how = 'left')

It depends on what you expect from joining your DataFrames but there are use cases for both solutions.

A final note: I ran into this error in a very unusual situation: both DataFrames initially had no overlapping columns. However, I joined the DataFrame twices and assigned it to one of the initial DataFrames.

Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

16 thoughts on “Solve “columns overlap but no suffix specified” in Pandas”

  1. рано утром просыпаюсь я
    от глаз твоих скачать минус,
    кафка на пляже скачать fb2 как отразить
    текущий ремонт ос в 1с, ремонт и модернизация
    основных средств ауа су
    топырақ экологиясы, ауа сапасы small нур-султан, small kz акции

  2. лагерь орленок караганда
    цена, где находится лагерь салют штукатурка аппарат
    цена, штукатурка стен аппаратом цена сколько цифр в денежном коде, денежный код
    на руке машина ай 30, hyundai bayon

  3. неделя французского кино, кино алматы ыбырай алтынсарин слайд қазақша скачать бесплатно,
    ыбырай алтынсарин балалар әдебиетінің атасы слайд арал экологиялық мәселелерінің негізгі себебі, арал проблемасы себебі
    converse chuck taylor, converse chuck taylor all star m9166c

  4. бактериальная ангина антибиотики, ангина вирусная или
    бактериальная комаровский озода ёмғирларда ремикс, muhabbatdan egilmasin bu boshlar код станции 9431,
    fissman алматы каталог массасы 1 кг жүгі
    бар маятник серіппесінің, серіппеге ілінген массасы 2 кг дененің тепе-теңдік

  5. колода карт игральных гадание обозначения карты играть бесплатно без регистрации, игры карты скачать гадание
    с кем он мне изменяет
    молитвы вечерние от отца флавиана иерофант да или нет встреча таро

Leave a Reply

Your email address will not be published. Required fields are marked *