I have a dataframe which has 80 columns. I want to replace some random columns with different values. I found some solution where we use df["c"] = mylist. but what if i want to randomly select a column and i don't know the column name. Something like, colNum = 12, and then i do df[colNum] = mylist. Here is the code i tried but with no luck:
def poisonData(data):
newValues = []
for i in range(6):
colNum = np.random.randint(0,81)
temp=data.iloc[:,colNum]
for x in temp:
newValues.append(float(x*colNum))
se = pd.Series(newValues)
data.columns[colNum] = se.values
return data
i also tried data.iloc[:,colNum] = se.values. I can't find what i am doing wrong :(