I have a Dataframe, df, with 3 columns: Year, Month and Date. I want to use this information to determine if this date falls on a weekend or weekday and which day of the week it is.
I am trying to use the below code to determine if its weekend or weekday but it is not working
from datetime import datetime
from datetime import date
def is_weekend(d = datetime.today()):
return d.weekday() > 4
df['weekend'] = df.apply(lambda x: is_weekend(date(x['Year'], x['Month'], x['Day'])), axis=1)
I am getting this error:
TypeError: cannot convert the series to <class 'int'>
Apart from this, how do I find out if this date falls on which day of the week.