Apr-04-2020, 03:43 AM
i have a text file with 3 lines :
1,2,3
1,2,4
1,2,5
df:[['1,2,3']
['1,2,4']
['1,2,5']]
how to convert it to integers?
i want the output to be
[[1,2,3]
[1,2,4]
[1,2,5]]
1,2,3
1,2,4
1,2,5
import pandas as pd import numpy as np df= pd.read_fwf("sample.txt",header =None) df= df.to_numpy() print("df:",df)running my code gives me a result of
df:[['1,2,3']
['1,2,4']
['1,2,5']]
how to convert it to integers?
i want the output to be
[[1,2,3]
[1,2,4]
[1,2,5]]