将列表作为一行添加到数据框中

时间:2021-03-02 11:42:53

标签: python pandas dataframe

我正在尝试在 Dataframe 中添加一个列表作为一行,我想知道为什么这个解决方案不起作用:

Bp = ["Nose", "Neck", "RShoulder", "RElbow", "RWrist", 
                    "LShoulder", "LElbow", "LWrist", "MidHip", "RHip", "RKnee", 
                    "RAnkle", "LHip", "LKnee", "LAnkle", "REye", "LEye", "REar", 
                    "LEar", "LBigToe", "LSmallToe", "LHeel", "RBigToe", "RSmallToe", 
                    "RHeel"]

BpDisp = pd.DataFrame(columns = Bp)

infoPos= [1001.36, 1001.33, 924.677, 886.404, 895.2239999999999, 1089.41, 1118.83, 1118.96, 1007.08, 954.15, 974.779, 977.5219999999999, 1065.85, 1057.14, 1048.4, 983.533, 1024.7, 954.227, 1048.26, 1060.1, 1077.74, 1045.23, 968.803, 951.097, 983.503]

to_add = pd.Series(infoPos, index = BpDisp.columns)

BpDisp.append (to_add, ignore_index = True)

我得到一个空的数据框:

Empty DataFrame
Columns: [Nose, Neck, RShoulder, RElbow, RWrist, LShoulder, LElbow, LWrist, MidHip, RHip, RKnee, RAnkle, LHip, LKnee, LAnkle, REye, LEye, REar, LEar, LBigToe, LSmallToe, LHeel, RBigToe, RSmallToe, RHeel]
Index: []

0 个答案:

没有答案