The relevant code you talk about in the linked question is:
df1 = pd.DataFrame({'a': [1, 2]})
df2 = pd.DataFrame({'b': [3, 1]})
df1.columns = [['b']] # WRONG
df1.columns = ['b'] # CORRECT
df1.merge(df2, on='b')
df.columns
must be a list of column labels1, each representing the name of a column. In the wrong version, you're setting it to be a one-element list whose element is itself a list (NOT a string), and thus the error.
1 column labels is straight from the documentation of DataFrame.columns
, strings are a type of valid values (although not the only one, see the comments below). Lists, on the other hand, generate a MultiIndex (try print (df1.columns)
after the "wrong" version), which causes problems later in the call to merge
.