0

Assume that there is a pandas data frame containing two columns, A and B; where : B = f(A) <<e.g. B=3*A>>. And we already have some data in it.

data = {'A' : [2, 4]}
df = pd.DataFrame(data)
df['B'] = 3 * df.A

Now, if I change a value of column A, it won't apply to column B. for example if:

df['A'][0] = 5

the desired result for B[0] would be 15, but it's not happening by doing so. Is there any way to change the value of B[0] automatically?

FZL
  • 133
  • 6

0 Answers0