我想使用函数在数据框中添加一行
features = pd.read_csv("Work.csv")
这是函数:
def classify(Res,O,S,R,Rear,F,L,B):
features = pd.DataFrame(np.array([[Res,O,S,R,Rear,F,L,B]]),
columns=['Resolution','OS','Storage','RAM',
'RearCamera','FrontCamera','LoudSpeaker','Battery'])\
.append(features, ignore_index=True)
当我将该函数称为:
classify(19283,"lolipop","fr","gg","ff",0,0,0)
我收到以下错误:
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-4-7c16987ef1b2> in <module>()
----> 1 classify(19283,"lolipop","fr","gg","ff",0,0,0)
<ipython-input-3-c620ec52544a> in classify(Res, O, S, R, Rear, F, L, B)
1 def classify(Res,O,S,R,Rear,F,L,B):
2
----> 3 features = pd.DataFrame(np.array([[Res,O,S,R,Rear,F,L,B]]), columns=['Resolution','OS','Storage','RAM','RearCamera','FrontCamera','LoudSpeaker','Battery']).append(features, ignore_index=True)
UnboundLocalError: local variable 'features' referenced before assignment
我该如何解决?