lair.pcaps.filter_pcap_events#
- lair.pcaps.filter_pcap_events(data, events, level=None)[source]#
Filter a DataFrame to exclude rows within PCAP events.
- Parameters:
data (pd.DataFrame) – The DataFrame to filter.
events (pd.DataFrame) – The DataFrame of PCAP events.
level (str, optional) – If the DataFrame has a MultiIndex, the level to apply the mask to.
- Returns:
pd.DataFrame – The DataFrame without the rows that fall within PCAP events.
- Return type:
See also
determine_pcap_eventsFinds the events.
build_pcap_maskThe mask it applies.
Examples
>>> import pandas as pd >>> from lair.pcaps import filter_pcap_events >>> events = pd.DataFrame( ... { ... "start": pd.to_datetime(["2024-01-01 12:00"]), ... "end": pd.to_datetime(["2024-01-03 11:59:59"]), ... } ... ) >>> times = pd.date_range("2024-01-01 00:00", periods=6, freq="12h") >>> data = pd.DataFrame({"ch4": range(6)}, index=times) >>> filter_pcap_events(data, events)["ch4"].tolist() [0, 5]