I tried to iterate through each row in a dataframe, and to do this - calculate_distance_from_SnS(row)
, then reassign the returned value (its a number).
The result is that it doesn't save the value under the specific column, what am I missing?
for example:
DF example
A B C
1 10 0
2 12 0
and I want to do this function C=A+B
for each row and get to this state:
A B C
1 10 11
2 12 14
I did this:
def calculate_distance_from_SnS(row):
using DF row and using 2 cols to calculate.
for i,row in customers.iterrows():
row['dist_from_sns'] = calculate_distance_from_SnS(row)