I would like to fill the values of a column based on a daytime filter (the DateTime values are in the index column) in python, pandas.
The problem I am facing is that my datetimes are already set as index, therefore, the "old way" I was solving this problem does not work.
So far for similar problems I was using this approach:
df.loc[df['filter'] > 0, 'column_value'] = 1
However now the 'filter' column is actually the index and I filter it between two dates, so there is no boolean in the first place.
So I tried:
df[df['2017.01.19 12:30:00':'2017.01.19 15:10:00'], "column_value"] = "something"
But I get the TypeError: 'DataFrame' objects are mutable, thus they cannot be hashed
type error.
If I try: df[df['2017.01.19 12:30:00':'2017.01.19 15:10:00']]
,
I get the Must pass DataFrame with boolean values only
error.
So please help me and let me know how to set the value of a column based on an indexed DateTime filter.
Thank you in advance.