Issue
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.
Solution
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]]
Answered By - G_M
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.