2

Data Frame:

Measure|Value
-------|----
A|1000
B|1000/
C|1000*
D|10
E|1000 0
F|1000
G|5..
H|2
I|w
K|288
L|
M|565

Results:

Measure|Value
-------|----
B|1000/
C|1000*
D|10
E|1000 0
G|5..
I|w
L|

In SQL I use query:

select Measure,Value from dataframe where isnumeric(value)=0 or patindex('%[^0-9.-]%', value)!=0

How to display non numeric values from data frame in python?

EdChum
  • 339,461
  • 188
  • 752
  • 538
Learnings
  • 2,450
  • 5
  • 30
  • 47
  • Possible duplicate of [finding non-numeric rows in dataframe in pandas?](https://stackoverflow.com/questions/21771133/finding-non-numeric-rows-in-dataframe-in-pandas) – FLab Jun 12 '17 at 09:23
  • @Ilja Everilä, I have checked, code: data.applymap(np.isreal) applies for all column, but I want to apply to Value column only. – Learnings Jun 12 '17 at 09:27

1 Answers1

2

Use str.isdigit with ~ to invert the boolean mask:

In[6]: df.loc[~df['Value'].astype(str).str.isdigit()]

Out[6]:
   Measure   Value
1        B   1000/
2        C   1000*
4        E  1000 0
6        G     5..
8        I       w
10       L     NaN

If the dtype of the column is already str then you don't need the astype(str) call

EdChum
  • 339,461
  • 188
  • 752
  • 538
  • I don't understand your comment, this answer does what you want – EdChum Jun 12 '17 at 12:58
  • @Linus sorry but asking a user to look at another question is poor etiquette on SO, SO is not a forum, you already have an accepted answer to that question so what's the problem? – EdChum Jun 12 '17 at 13:19