I have a data frame a below:
PT CA DE AP
0 1 2 [3,4,5,6]
1 4 6 [7,8,9]
when I save this data frame and read it again, the 'AP' column is stored as string:
PT CA DE AP
0 1 2 '(3,4,5,6)'
1 4 6 '(7,8,9)'
When I try to change it to integer by the following command, I got an error:
df.AP = df.apply(lambda r: [int(r.AP[j]) for j in range(len(r.AP))], axis = 1)
Error:
("invalid literal for int() with base 10: '('", 'occurred at index 0')
Could you please tell me how can I solve this issue?