I have some code like this but I got error from pylint and I don't know what's wrong with it and what should I do
tuples = ((1, 2), (4, 5), (7, 8))
for tuple_ in tuples:
df[df["date"].apply(lambda d:(d.month==tup[1]) & (d.year==tup[0]))].count()[0]
df is a pandas dataframe and "date" column is pandas datetime
code works well but there is error message from pylint
Update:
I just created small function that could remove pylint error but I want to know if my approach is a right one!
tuples = ((1, 2), (4, 5), (7, 8))
def _group_date(df_, tup_):
return df[df["date"].apply(lambda d:(d.month==tup[1]) & (d.year==tup[0]))].count()[0]
dict_ = {}
for tuple_ in tuples:
dict_[f"{tuple_ }"] = _group_date(df, tuple_ )