Wie man mehrere Zeilen aus einem pandas-DataFrame per Index entfernt
English
Deutsch
drop_rows_example.py
import pandas as pd
import numpy as np
# Beispiel-DataFrame mit Datetime-Index erstellen
dates = pd.date_range('2023-01-01', periods=10)
data = np.random.randn(10, 2)
df = pd.DataFrame(data, index=dates, columns=['A', 'B'])
# Zu entfernende Zeitstempel
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')]
# Zeilen entfernen
df_filtered = df.drop(index=timestamps_to_drop)If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow