i'm abstracting a lot of pandas functionality for an application i'm building. I have a scenario where I need to get the value from the target column where the first occurrence of an unknown number conditions evaluates to true. So something like this:
import pandas as pd
#lets say this dataframe already has data in it with column names and number index rows.
df = pd.Dataframe()
targetCols:list = [targetColName1, targetColName2]
compCols:list = [compColName1, compColName2]
compVals:list = [compVals1, compVals2]
#Some function that concatenates the compCols and compValues in to stirngs
# look like:
# (f"(df[['{compCols[0]}']=={compVals[0]}]) & "
# f"(df[['{compCols[1]}'] == {compVals[1]})")
strExeString = ConcatenateExecutonString(compCols, compVals)
dfView = pd.eval(strExeString)
dfView = dfView[targetCols]
return dfview.loc[0:]
However the above causes me to scan through the data set a lot, I want to simply scan the DataFrame once until my conditions are met and then extract the target columns. Can we do this with pandas? I can do this with native list objects but if I can use pandas I'd like to since it can handle large sets more efficiently.