I have a list of tuples that is created with the zip function. zip is bringing together four lists: narrative, subject, activity, and filer, each of which is just a list of 0s and 1s. Let's say those four lists look like this:
narrative = [0, 0, 0, 0]
subject = [1, 1, 0, 1]
activity = [0, 0, 0, 1]
filer = [0, 1, 1, 0]
Now, I'm ziping them together to get a list of boolean values indicating if any of them are True.
ny_nexus = [True if sum(x) > 0 else False for x in zip(narrative, subject, activity, filer)]
The problem I'm having now, is getting a second list of tuples for which the names of the variables is returned if it had a 1 during the iteration. I imagine it would look something like this:
variables = ("narrative", "subject", "activity", "filer")
reason = [", ".join([some code to filter a tuple]) for x in zip(narrative, subject, activity, filer)]
I just can't figure out how I'd go about this. My desired output would look like this:
reason
# ["subject", "subject, filer", "filer", "subject, activity"]
I'm somewhat new to Python, so I apologize if the solution is easy.
ny_nexus = [sum(x) > 0 for x in zip...]any()built-in function ;)any([0, 0, 0]) == False,any([0, 1, 0]) == True. So,ny_nexus = [any(x) for x in zip...]