My DataFrame db is built from a csv file, using read_csv. Values of column A look like this:
[1,2,5,6,48,125]
On every row, the "vector" can have a different length. But it is still a string. I can strip the [ and ] as follows:
db["A"] = db["A"].str.rstrip(']').str.lstrip('[')
The resulting values, such as 1,2,5,6,48,125, should be good input for np.fromstring. However, I am not able to apply this function in combination with pandas DataFrame.
When I try:
db["A"] = np.fromstring(db["A"], sep=','), it says:
a bytes-like object is required, not 'Series'.
Using apply also does not work. Thanks for any tips.