0

I have here an issue and would like to ask for support

Suppose you have a following frame

frame=pd.Dataframe({"Arbitary Number":[1,2,3,4]})

I want to add an additional column, whose entries are np.arrays. I add the entry the following way

frame["new col"]='[8,8,8,8]'

How ever in a later stage I need the entries as array. If I apply

frame["new col"]=frame["new col"].appy(np.array)

I still get object as column type and cannot use the entries to do some math work. I need to go the way with

np.array([eval(xxx)])

to have an array

The question is: Is there a nice and clean way to add arrays as column values without transforming them as strings before assigning them as value? Or if this is not the case and I do need to assign the list as string, is there a way to change the column type to np.array format? My mentioned solution is not working

Thanks a lot for any kind of help

Cheers

SMS
  • 348
  • 2
  • 13

0 Answers0