Question: I have three columns in a pandas dataframe that I want to convert into a single date column. The problem is that one of the columns is day column. I am not able to convert into exact date of that month and year. Can anyone please help me to solve this issue. It looks something like this:

```
   BirthMonth BirthYear Day
0   5           88      1st Monday
1   10          87      3rd Tuesday
2   12          87      2nd Saturday
3   1           88      1st Tuesday
4   2           88      1st Monday

```

Answer: 
Based on your reply to my first comment I updated my answer as follows. I think this is what you are looking for:

```
import re
import time
import calendar
import numpy as np

days = ['1st Monday', '3rd Tuesday', '4th wednesday']
months = [2, 3, 5]
years = [1990, 2000, 2019]

def extract_numeric(text: str):
    return int(re.findall(r'\d+', text)[0])

def weekday_to_number(weekday: str):
    return time.strptime(weekday, "%A").tm_wday

def get_date(number: int, weekday: int, month: int, year: int) -> str:
    """ 3rd Tuesday translates to number: 3, weekday: 1 """
    firstday, n_days = calendar.monthrange(year, month)
    day_list = list(range(7)) * 6
    month_days = day_list[firstday:][:n_days]
    day = (np.where(np.array(month_days) == weekday)[0] + 1)[number - 1]
    return '{}/{}/{}'.format(day, month, year)

numbers = []
weekdays = []
for day in days:
    number, weekday = day.split()
    numbers.append(extract_numeric(number))
    weekdays.append(weekday_to_number(weekday))

dates = []
for number, weekday, month, year in zip(numbers, weekdays, months, years):
    dates.append(get_date(number, weekday, month, year))

print(dates)  # ['5/2/1990', '21/3/2000', '22/5/2019']

```
**Edit** to match SO new dataframe

My solution using pandas dayofweek function:

```
import numpy as np
import pandas as pd
from datetime import date
from dateutil.relativedelta import relativedelta

#generate dataframe
df=pd.DataFrame({'BirthMonth':[5, 10, 12, 1 ,2],
         'BirthYear':[88, 87, 87, 88, 88],
         'Day':['1st Monday', '3rd Tuesday', '2nd Saturday','1st Tuesday','1st Monday']})
#Assuming the year refers to 19xx
df.BirthYear=1900+df.BirthYear
#list of day names
weekday=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']

#Identify day name in input df
days_ex=[s.split()[1].title() for s in df.Day]

#initialize output list
dateout= ["" for x in range(len(days_ex))]
for j in range(len(days_ex)):
    #Identify the day number in the week (Monday is 1, Sunday is 7)
    daynum=np.nonzero(np.char.rfind(weekday,days_ex[j])==0)[0][0]

    #create start and end date for the month
    date_start=date(df.BirthYear[j],df.BirthMonth[j],1)
    date_end=date_start+relativedelta(months=+1)

    #daily index range within month of interest
    idx=pd.date_range(date_start,date_end,freq='d').dayofweek

    # Find matching date based on input df
    realday=np.where(idx==daynum)[0][int(df.Day[j][0])-1]+1
    #output list
    dateout[j]=str(realday)+'/'+str(df.BirthMonth[j])+'/'+str(df.BirthYear[j])

```

the result i got is:

```
['2/5/1988', '20/10/1987', '12/12/1987', '5/1/1988', '1/2/1988']

```