How to remove apostrophe from List in Python

I'm developing a machine learning program with Python but I'm having an issue with the line of code below

 [['23,24,-23,12,32,54,64,12,4,0,13,10']] 

I want to transform this data with LinearDiscriminantAnalysis But I want the apostrophe to be removed. I want my output to be:

[[23,24,-23,12,32,54,64,12,4,0,13,10]] 

I do not what the ' before and after [ ]. Thanks in anticipation.

1 answer

  • answered 2018-10-09 16:33 G_M

    In[2]: a = [['23,24,-23,12,32,54,64,12,4,0,13,10']]
    In[3]: result = []
    In[4]: for sublist in a:
      ...:     for elem in sublist:
      ...:         result.append([int(b) for b in elem.split(',')])
      ...: 
    In[5]: result
    Out[5]: [[23, 24, -23, 12, 32, 54, 64, 12, 4, 0, 13, 10]]