1

I am using for loop to combine dataframe column list elements from index zero to a certain index. The list elements somehow changed to type str which I have discussed here and used the solution as given in link i.e. ids = ids['IDs'].apply(literal_eval).sum(). This solution works fine but it gives the syntax error before loop is completed. I used try: ids = ids['IDs'].apply(literal_eval).sum() except (ValueError, SyntaxError): pass and found out that instead of taking the list values, it starts taking the column name and converts it into [('I', 'D', 's')]. That's where I get syntax error. The code before this line prints the list values perfectly well and does not have this problem. Can someone help me out with this?

Community
  • 1
  • 1
SarwatFatimaM
  • 315
  • 1
  • 3
  • 13

0 Answers0