I have a function below to find how many days in a month
import calendar
calendar.monthrange(2012,2)[1]
This return 29
My question is, now I have a dataframe that contains 100+ (Year,Month)
2012,2
2012,3
2013,1
2016,7
2015,4
...
I have defined the dataframe as df['Year'] and df['Month'], and when I insert those two into the function
import calendar
calendar.monthrange(df['Year'],df['Month'])[1]
It tells me that ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
How do I use this function with my dataframe or I have to manually type in those inputs in the function?
Thank you