-1

question editted to avoid duplication

I have a pandas dataframe with A, B, C, D , E columns:

A B C D E

X 2 3 - 5

Y Â 3 4 Â

Z - - Â 5

I would like to remove all non-machine readable characters (Â) and non-numeric characters (-) from column B onwards and replace them with NaN.

Thanks

Analyst
  • 139
  • 2
  • 9

1 Answers1

2

Using where

df.where(df.applymap(
    lambda x: str(x).isdigit()
))
piRSquared
  • 285,575
  • 57
  • 475
  • 624
  • Thanks. This works. A followup; if I only wanted to remove non-machine readable characters from the frame (i.e. keep standard text), how would I modify this? – Analyst Apr 23 '18 at 13:55