(Dec-27-2018, 02:41 PM)SriRajesh Wrote: but it does not print give any output.He do it from interactive shell.
Like this without:
import re regex = re.compile(r"\d*E\d*") match = regex.search('VN009K30E6T00') aa = match.group() print(aa)
SriRajesh Wrote:I have below DataFrame:When using pandas,you should not take it out of DataFrame and use regex.
pandas has build in regex(
str
) to deal with DataFrame.Example:
import pandas as pd df = pd.DataFrame( [['VA004L200E2T99',77, 999], ['VG002K500E4T99',55, 100], ['VN009K30E6T00',33, 9]], columns=['val','foo', 'bar'] ) df['val'] = df['val'].str.extract(r'(\d*E\d*)', expand=False) print(df)
Output: val foo bar
0 200E2 77 999
1 500E4 55 100
2 30E6 33 9