I have a Pandas dataframe. For each row in this frame I want to make a certain check. If the check yields True
, then I want to add certain columns of the dataframe-row to a list-structure.
How can I access a list from within the apply function without the need to create a global list variable? Is this possible? Or is there a better way to do this?
The code looks like this:
df.apply(checkFunction, axis=1)
checkFunction(row):
if (check == True):
myList.append(row)
return row