Try this:
import numpy as np
df['opens'] = (
df['opens']
.str.strip('[')
.str.strip(']')
.str.strip(' ')
.str.replace(', ', ',')
.str.split(',')
.apply(np.array, dtype=float)
)
The error you're getting (ValueError: could not convert string to float: '[[63.240001
) is due to the fact that the values from the column opens
are being read as strings, instead of lists of values.
For example, the first value of opens
being read is:
"[63.2400016784668, 62.20000076293945, 61.91999816894531, 61.40000152587891, 60.65999984741211, 60.04000091552734, 61.27999877929688, 60.0, 59.11999893188477, 57.88000106811523, 57.7599983215332, 59.04000091552734, 58.18000030517578, 55.29999923706055, 54.13999938964844, 54.52000045776367, 54.13999938964844, 56.72000122070312, 57.0, 58.29999923706055, 58.34000015258789, 58.04000091552734, 58.5, 58.45999908447266, 58.34000015258789, 56.09999847412109, 56.72000122070312, 58.5, 59.13999938964844, 58.41999816894531, 58.65999984741211, 57.90000152587891, 56.43999862670898, 55.7599983215332, 56.27999877929688, 55.22000122070312, 56.5, 56.58000183105469, 56.72000122070312, 56.38000106811523, 55.72000122070312, 55.88000106811523, 56.7400016784668, 58.06000137329102, 58.79999923706055, 59.40000152587891, 59.56000137329102, 58.18000030517578, 58.11999893188477, 57.72000122070312, 57.79999923706055, 56.88000106811523, 57.31999969482422, 56.11999893188477, 56.59999847412109, 56.38000106811523, 57.15999984741211, 56.08000183105469, 56.93999862670898, 57.86000061035156, 57.88000106811523, 58.54000091552734, 58.70000076293945, 57.81999969482422, 58.68000030517578, 58.58000183105469]"
instead of something like:
['63.2400016784668',
'62.20000076293945',
'61.91999816894531',
'61.40000152587891',
'60.65999984741211',
'60.04000091552734',
'61.27999877929688',
'60.0',
'59.11999893188477',
'57.88000106811523',
'57.7599983215332',
'59.04000091552734',
'58.18000030517578',
'55.29999923706055',
'54.13999938964844',
'54.52000045776367',
'54.13999938964844',
'56.72000122070312',
'57.0',
'58.29999923706055',
'58.34000015258789',
'58.04000091552734',
'58.5',
'58.45999908447266',
'58.34000015258789',
'56.09999847412109',
'56.72000122070312',
'58.5',
'59.13999938964844',
'58.41999816894531',
'58.65999984741211',
'57.90000152587891',
'56.43999862670898',
'55.7599983215332',
'56.27999877929688',
'55.22000122070312',
'56.5',
'56.58000183105469',
'56.72000122070312',
'56.38000106811523',
'55.72000122070312',
'55.88000106811523',
'56.7400016784668',
'58.06000137329102',
'58.79999923706055',
'59.40000152587891',
'59.56000137329102',
'58.18000030517578',
'58.11999893188477',
'57.72000122070312',
'57.79999923706055',
'56.88000106811523',
'57.31999969482422',
'56.11999893188477',
'56.59999847412109',
'56.38000106811523',
'57.15999984741211',
'56.08000183105469',
'56.93999862670898',
'57.86000061035156',
'57.88000106811523',
'58.54000091552734',
'58.70000076293945',
'57.81999969482422',
'58.68000030517578',
'58.58000183105469']