How to drop multiple rows from pandas DataFrame by index
import pandas as pd
import numpy as np
# Create a sample DataFrame with datetime index
dates = pd.date_range('2023-01-01', periods=10)
data = np.random.randn(10, 2)
df = pd.DataFrame(data, index=dates, columns=['A', 'B'])
# Timestamps to drop
timestamps_to_drop = [pd.Timestamp('2023-01-03'), pd.Timestamp('2023-01-05'), pd.Timestamp('2023-01-07'),
pd.Timestamp('2023-01-08'), pd.Timestamp('2023-01-10')]
# Drop rows
df_filtered = df.drop(index=timestamps_to_drop)