3

I have a problem, very similar to the one in this question. Where I am trying to modify a subset of rows in my dataframe.

The only difference being that instead of using values from the column itself as shown here

df.ix[df.A==0, 'B'] = df.ix[df.A==0, 'B'] / 2

I want to use a different column, let's call it C and apply a function to it and assign it to column B so something like this.

df.ix[df.A==0, 'B'] = df.ix[df.A==0, 'C'].apply(function)

But I cannot get it to behave how I expect. Any ideas?

Community
  • 1
  • 1
  • 2
    How does it behave and how would you expect it to work? Please include a sample dataset and desired output to your question. – ayhan Jul 05 '16 at 20:56
  • if i try your code, applying vectorized function (which works with column(s)) - it works properly for me, so I guess there is something "strange" with your function... Can you post your function? – MaxU - stand with Ukraine Jul 05 '16 at 21:58
  • It is working as expected! I made a mistake in assuming a few of my rows would fall under the "A==0" condition when they in fact did not so when they were not changing I assumed it was not the correct method. Thanks everyone for taking a look and advising. – Andres Mora Jul 06 '16 at 13:01

0 Answers0