-3

Trying to load data from a csv file.

There's an object in file as follows:

[13 12 12 13 12 12]

dtype('O') as shown when I tried object'.values.dtype

how to convert to numeric list?

Tried astype(str), not working either.

shaik moeed
  • 5,300
  • 1
  • 18
  • 54

1 Answers1

0

Assuming you have that as a string then:

s = '[13 12 12 13 12 12]'

print([int(x) for x in s[1:-1].split()])

Output:

[13, 12, 12, 13, 12, 12]
DarkKnight
  • 19,739
  • 3
  • 6
  • 22