I am trying to iterate through a dataframe, classify each row and add the output to the end of the row in a new column.
It seems to be adding the same classification to every row
dfMach = pd.read_csv("C:/Users/nicholas/Desktop/machineSum.csv", encoding='latin-1')
dfNew = dfMach
dfNew["Classification"] = ""
for index, row in dfMach.iterrows():
aVar = dfMach['Summary'].iat[0]
aClass = cl.classify(aVar)
dfNew['Classification'] = aClass
Where am I going wrong?
Thank you
row['Summary']instead ofdfMach['Summary']. Its better you go for applyrow['Summary']?