-1

I have string None & other string values in dataframe columns, I want to empty all "None" and keep others.

df[['status','Amount']].replace("None", " ",inplace=True)

The "None" still in columns, How can remove them PERMANENTLY? THANK YOU

jpp
  • 159,742
  • 34
  • 281
  • 339
Ray
  • 53
  • 6
  • Possible duplicate of [How to replace None only with empty string using pandas?](https://stackoverflow.com/questions/31295740/how-to-replace-none-only-with-empty-string-using-pandas) – jpp Nov 17 '18 at 23:23
  • I did but didn’t work – Ray Nov 18 '18 at 02:47

1 Answers1

0

There are a few different ways to do this. I am not sure how the rest of your code looks, but I would do something along the lines of:

d = {'status': statusArray, 'Amount': amountArray}
df = pd.DataFrame(data = d)
df.replace(regex = "None", value = "", inplace = True)

https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.replace.html this is the reference page for the pandas.DataFrame.replace there are good examples at the bottom for the other ways to do this.

AnnaB
  • 121
  • 2
  • 7
  • I just tested this and edited my answer, the issue was inplace defaults to False and we need to set it to True at the end of the replace statement. Thanks for the heads up, this should work now. – AnnaB Nov 18 '18 at 09:50