import pandas as pd df = pd.DataFrame({ "col1": [1, 2, 3, 1, 2, 3], "col2": ["A", "B", "A", "B", "A", "B"] }) c = r"(df['col1'] == 1) | (df['col2'] == 'A')" df[eval(c)] df[df['col1'] == 1] d = "df['col1'] == 1" df[eval(d)]
No comments:
Post a Comment