I m going to provide an answer based on the following dataframe example (you had to provide one actually):
columnA columnB
NameA 2016-01-01 12:00:00 p a
2017-01-01 12:00:00 q b
NameB 2018-01-01 12:00:00 r c
NameC 2019-01-01 12:00:00 s d
how can I drop one row with a certain 'name' and 'timestamp' index?
Lets say you want to drop name with 'NameA' and timestamp with '2017-01-01 12:00:00' then you could use:
df.drop(('NameA', pd.Timestamp(2017, 1, 1, 12)), axis=0)
output:
columnA columnB
NameA 2016-01-01 12:00:00 p a
NameB 2018-01-01 12:00:00 r c
NameC 2019-01-01 12:00:00 s d
how can I drop multiple rows for one name and a list of timestamps?
You can use pd.MultiIndex.from_product to create a multiindex that you want to drop.
Example: you want to drop the two timestamps that are for 'NameA':
df.drop(
pd.MultiIndex.from_product([
['NameA'],
[pd.Timestamp(2016, 1, 1, 12), pd.Timestamp(2017, 1, 1, 12)]]),
axis=0
)
output:
columnA columnB
NameB 2018-01-01 12:00:00 r c
NameC 2019-01-01 12:00:00 s d