-1

I'm still relatively new to ipython and am trying to do some data transformation. I am using the data from an email blast in order to determine the effectiveness of the action and one of the factors that I would like to use is determining the amount of dollars spent by each customer after the blast. As you can guess, there are a lot of "0"s in there and it skews this particular portion of the analysis.

My question is, how do I just drop the 0 values in this column while leaving the customer information for those who have spent money intact. I've been trying to experiment with making 0 a null value, but I don't know the right sequence of code. "spend" is the name of the column that I'm attempting to change

dfspend = df1.replace({'spend': 0}, {'spend': isnull})

This is a rough idea of what I've been trying to do, except that the isnull is invalid.

Thomas K
  • 39,200
  • 7
  • 84
  • 86
  • Hey Trevor, can you more explicit on the code you are using and what error message you are getting (or another explanation of what is not working). It is not clear what '0' represents in your question above. Have you looked at other questions on here relating to replace, like http://stackoverflow.com/questions/23307301/pandas-replacing-column-values-in-dataframe – tjb305 Apr 23 '16 at 09:52

1 Answers1

0

Try this:

import numpy as np
df1.ix[df1.spend == 0, 'spend'] = np.nan

I hope this helps

Thanos
  • 2,472
  • 1
  • 16
  • 33