I am trying to get 1st (0) and 2nd (1) strings in a tuple at a df.
df= {'col':[ "[('affect', 'the risks')]", "[('have', 'we'), ('breached', 'our systems'), ('cease', 'our computer'), ('suffer', ''), ('allow', ''), ('damage', 'misappropriation'), ('require', 'proprietary'), ('incur', 'us'), ('remediate', 'us'), ('resolve', 'us')]"]}
df = pd.DataFrame(df)
such that, the expected output for item0 and item1 should be:
df={'item0': [ "'affect'", "'have', 'breached','cease', 'suffer',' allow', 'damage' , 'require', 'incur', 'remediate', 'resolve'"]}
df={'item1': [ "'the risks'", "'we', 'our systems','our computer', '', 'misappropriation', 'proprietary', 'us', 'us', 'us'"]}
df = pd.DataFrame(df)
I think we should use zip() function but I couldnot figure it out because I have a dataframe here.
Resources I went through: 1)https://docs.python.org/3/tutorial/datastructures.html#nested-list-comprehensions 2) Python - List comprehension list of tuple list to tuple list