Apr-17-2024, 04:09 PM
It is possible to make a new dataframe that consists of selected columns of another dataframe. If the signal names follow some pattern this can be done using "like".
import pandas as pd import random data = { "time": range(1000, 1010), "sw1": random.choices([0, 1], k=10), "sw2": random.choices([0, 1], k=10), "tmp1": [random.random() * 5 + 10 for _ in range(10)], "sw3": random.choices([0, 1], k=10), "tmp2": [random.random() * 5 + 11 for _ in range(10)], "tmp3": [random.random() * 5 + 12 for _ in range(10)], } df = pd.DataFrame(data) switches = df.filter(regex=r"(time)|sw.$") temperatures = df.filter(regex=r"(time)|tmp.$")