I am not very experienced in python. I have a problem subsetting a multindex dataframe by giving two string dates. Your help is very much appreciated.
result = run_pipeline(pipeline, start_date="2006-01-01", end_date="2008-08-01")
and I want to get a slice between two dates: '2006-01-01' and '2007-01-01'
Here is what I do and what I get:
dti = result.index.get_level_values(0)
query = ( dti> '2006-01-01') & (dti< '2007-01-01')
res = result.loc[query]
print(res.index.levels[0])
No slicing is done
DatetimeIndex(['2006-01-03', '2006-01-04', '2006-01-05', '2006-01-06',
'2006-01-09', '2006-01-10', '2006-01-11', '2006-01-12',
'2006-01-13', '2006-01-17',
...
'2008-07-21', '2008-07-22', '2008-07-23', '2008-07-24',
'2008-07-25', '2008-07-28', '2008-07-29', '2008-07-30',
'2008-07-31', '2008-08-01'],
dtype='datetime64[ns, UTC]', name='date', length=650, freq='C')