I have two dataframes:
daily = pd.DataFrame({'Date': pd.date_range(start="2021-01-01",end="2021-04-29")})
pc21 = pd.DataFrame({'Date': ["21-01-2021", "11-03-2021", "22-04-2021"]})
pc21['Date'] = pd.to_datetime(pc21['Date'])
what I want to do is to create another column for daily with values 1 if dates in pc21 are in daily and 0 otherwise. This is my code:
l=[]
 for i in range(len(pc21['Date'])):
       x = daily['Date'].eq(pc21['Date'][i]).astype(int)
       l.append(x)
       
print(l)
# I also tried:
 for i in range(len(pc21['Date'])):
       daily['newcol'] = daily['Date'].eq(pc21['Date'][i]).astype(int)
       daily['newcol'].append(daily['newcol'])
       
However, I only get saved (for the first code) the last value.
What am I doing wrong?
Can anyone help me?
Thanks!
 
     
     
    