Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have a df with values in a column. df :
df
a 0 abc_test_0120_12346 1 def_abc def_0420_9658
I want to take out only int/numbers. Excepted Output is df :
a 0 012012346 1 04209658
df.a.str.extract('(^\d*)')
Idea is replace non numbers to emty strings:
df['a'] = df.a.str.replace('\D+', '') print (df) a 0 012012346 1 04209658
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
df.a.str.extract('(^\d*)')