0

pyspark 2.3.1

my rows to col1 should only contain integers. I am trying to filter out any row that have even one character. How can I do this in pyspark?

I've tried

df.select('col1').filter(df.col1.rlike(^[a-zA-Z])) 

however rows that contain alphabet also contain integers therefore not filtered.

How can I do this?

0

1 Answer 1

1

You can try to select pure digital rows.

df = df.filter('col1 rlike "^[0-9]+$"') df.show(truncate=False) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.