I want to assign data to a column of the data frame using for loop and a function but I got the common warning:
"SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame"
I have a data frame and three columns of date(year, month and day) and now I want a new column which converts those three columns to one.
I am using a for loop to assign the new data to the new column.
I tried to use copy() and deepcopy() as you can see below but it does not work.
for i in range(100008):
df.new_col[i]=convert(df.year[i],df.mounth[i],df.day[i])
what I tried instead of second line:
df.new_col[i].copy()=convert(df.year[i],df.mounth[i],df.day[i])
deepcopy(df.new_col[i]) =convert(df.year[i],df.mounth[i],df.day[i])
I expected my code to assign the values to the column and it does(as I interrupted the kernel and called the df) but it takes many hours to do this. How can I fix the problem?