I am trying to read a csv, add columns and then set values for each cell in the new columns. but I can the below error
raise Exception("cannot handle a non-unique multi-index!")
Exception: cannot handle a non-unique multi-index!
My csv data does not have any index column, I don't know how add an incremental numeric index column to it.
I tried print("data.columns = ", data.columns) but I can see all of the columns are part of the index which is incorrect.
data = pd.read_csv( filename, names=colnames, header=None )
# data = data.drop(['datetime'], axis=1)
data[ "positive" ] = 0
data[ "negative" ] = 0
data[ "hate_speech" ] = 0
data[ "neither" ] = 0
data[ "count" ] = 0
data[ "class" ] = -1
print("data.columns = ", data.columns)
for j in range(0, data.shape[0]):
tweet_set = set( str(data[ "tweet" ][ j ]).split() )
pos_count = len(pos_set.intersection( tweet_set ))
data.at[ j , "positive"] = pos_count