If you want a vectorial transformation, I would suggest to use pandas's to_datetime:
import pandas as pd
ray = pd.to_datetime(ray).values
Output:
array(['1988-01-01T00:00:00.000000000', '1999-01-01T00:00:00.000000000',
'1987-01-01T00:00:00.000000000', '1989-01-01T00:00:00.000000000',
'1996-01-01T00:00:00.000000000', '1995-01-01T00:00:00.000000000',
'1995-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
Notes. I'm assuming a MM.DD.YY format, if DD.MM.YY use dayfirst=True as parameter of to_datetime. Also, using values and not to_numpy() on purpose to avoid the unnecessary copy of the underlying array.
To have the years as strings:
out = pd.to_datetime(ray).strftime('%Y').values
Output:
array(['1988', '1999', '1987', '1989', '1996', '1995', '1995'],
dtype=object)
As integers:
out = pd.to_datetime(ray).year.values
Output:
array([1988, 1999, 1987, 1989, 1996, 1995, 1995])
.22mean 2022 or 1922?dtype.