I have the following code.
I am trying to check if a 'date-time' value in the column numberofeachconditiononthatdate['Date'] is in the column 'luckonthatdate['Date']'.
If it is, then I want that particular date-time value to be assigned to the variable 'value'.
If not, then I want the variable 'value' to equal 0.
In other words, I want to create a new column of values to the 'numberofeachconditiononthatdate' dataframe, indicating the number of 'luck' trials on a given date.
luckvalues = []
for idx in numberofeachconditiononthatdate.iterrows():
if numberofeachconditiononthatdate['Date'][[idx]].isin(luckonthatdate['Date']):
value = luckonthatdate['Date'][[idx]]
luckvalues = luckvalues.append(value)
else:
value = 0
luckvalues = luckvalues.append(value)
print(luckvalues)
However, this gives me the error 'unhashable type: 'Series''.
I would be so grateful for a helping hand!
numberofeachconditiononthatdate['Date']
0 2020-04-06
1 2020-04-06
2 2020-04-06
3 2020-05-06
4 2020-05-06
5 2020-05-06
6 2020-06-06
7 2020-06-06
8 2020-06-06
9 2020-06-13
luckonthatdate['Date'].head(10)
0 2020-04-06
3 2020-05-06
6 2020-06-06
9 2020-06-13
16 2020-10-06
20 2020-11-06
23 2020-12-06