从浮点值列表创建DataFrame

时间:2019-05-31 16:23:14

标签: python pandas dataframe

我有一个包含浮点值的列表,我想用它制作一个DataFrame。但是我收到一个错误TypeError:'float'对象不可迭代

    '''python   
       newlist = []
       for i in path.toolpath:   
            newlist = [i.x, i.y,i.z, i.e, i.moveSpd]
            labels = ['x_coordinate' , 'y_coordinate', 'z_coordinate', 'e', 'speed'] 
       df1 = pd.DataFrame.from_records(newlist, columns = labels)
       print(df1)
    '''

A part of newlist is as follows.
    [-40.8629, 2.28, 44.3492, 1698.7625, 300]
    [-40.788, 2.28, 43.352, 1699.0625, 300]
    [-40.7131, 2.28, 42.3548, 1699.3625, 300]
    [-40.6382, 2.28, 41.3576, 1699.6625, 300]
    [-40.5633, 2.28, 40.3604, 1699.9625, 300]

1 个答案:

答案 0 :(得分:1)

您的new_list变量将被覆盖,您需要附加该值。 像这样

struct some *azaza = ptr;