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
  • 376,765
  • 198
  • 813
  • 562
Learnings
  • 2,780
  • 9
  • 35
  • 55
  • 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
  • 376,765
  • 198
  • 813
  • 562