Q:

Parsing column values in python pandas

I have about 200.000 rows in df and 20 columns, and one column contains a name of the station. It looks like this:
00001 OPPT YY G
00002 LIMO DA G
000016 KAPAL VS G
0000663 TAPS VS G
...

What is the best way to take just numbers from column values? 
Desired output:
00001
00001
000016
0000663

Thanks

A:

Assuming Col1 is your column
df
Out: 
                Col1
0    00001 OPPT YY G
1    00002 LIMO DA G
2  000016 KAPAL VS G
3  0000663 TAPS VS G

Split on space and take the first element:
df['Col1'].str.split().str[0]
Out: 
0      00001
1      00002
2     000016
3    0000663
Name: Col1, dtype: object

