I have a dataframe called df1:
df1 = pd.DataFrame(minor_scales, columns = [“major”, “minor”, “7th”, “5th”,
“dim”, “dim7”, “aug”, “sus2”, “sus”,
“maj7”, “minor7”, “7sus4”, “maj9”,
“maj11”, “maj13”, “maj9(b5)”], index = list(minor_scales.keys()))
now I want to add new chords to this dataframe by defining a new function. But, adding a new element to a related index and column is a problem:
def chord_adder():
#dim7
a = 0
df1[“dim7”] = df1[“dim”]
for index in df1.index:
val = list(copy.deepcopy(major_scales).values())[a]
df1[“dim7”] = df1[“dim7”]._append(val[5])
a += 1
return df1
Now as you see, I firstly add the notes which allready exist in dim7 chords, and want to add the 6th note of the major scale of the cord. (dim7 column is allready created by adding 1, b3 and b5 notes of the major scale.)
However, I can’t find a way to append the notes to the related column. I keep getting the TypeError: cannot concatenate object of type ‘<class ‘numpy.int64′>’; only Series and DataFrame objs are valid.
What is the type of the objects that are in the columns? What should I do to add new elements to the related index and the column?
thanks!
özgün yılmaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.