fork download
  1. import pandas as pd
  2. import re
  3.  
  4.  
  5. df1 = {'IDNumber': ['1', '2', '3'], 'Title': ["Vauxhall Astra Model H 92-93", "VW Golf MK2 GTI 90-91", "BMW 1 Series 89-93"]}
  6. df2 = {'Manufacturer': ["VW", "VW", "VW", "Vauxhall", "BMW", "BMW"], 'Model': ["Golf", "Golf", "Golf", "Astra", "2 Series", "1 Series"], 'Type': ['MK2', 'MK2 GTI', 'MK2', 'Model H', '', ''], 'Year': ["1990|1991|1993", "1990|1991|1993", "1896|1897|1898|1899", "1991|1992|1993|1994", "2000|2001|2002", "1889|1890|1891|1892|1893"], 'Tag': ['1000', '1001', '1002', '1003', '1004', '1005']}
  7.  
  8.  
  9. # split title of df1 into string and year tag min and year tag max
  10. regular_expression = re.compile(r'\d\d-\d\d')
  11.  
  12. title_string = df1['*Title']
  13.  
  14.  
  15. year_min = title_string.apply(lambda x: regular_expression.search(x)[0].split('-')[0])
  16.  
  17. year_max = df1['*Title'].apply(lambda x: regular_expression.search(x)[0].split('-')[1])
  18.  
  19. print(year_min)
Runtime error #stdin #stdout #stderr 0.52s 65584KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 12, in <module>
KeyError: '*Title'