I’m going over the array tutorial trying to see how to add 1 to the content of an array but am having difficulties. I do not want to replace the contents of the column by 1, but add 1 to the value already in the column. What is the correct way to do this for an array and dataframe?
QWER = rand(5, 5)
QWER[:,2:4] .+1 #this adds 1 to the selected columns
QWER # but this change does not occur in the array
QWER[:,2:4] .= .+1 # this changes the column values to 1
QWER # this change occurs in the array
using DataFrames
df_QWER = DataFrame(QWER)
df_QWER[:,2:4] = .+1 # this changes the column values to 1
df_QWER # this change occurs in the array
df_QWER = DataFrame(QWER)
df_QWER[:,2:4] .+1 # this adds 1 to the selected columns
df_QWER # but this change does not occur in the array