私は一連の合成データを作成しようとしています。私はPython 3.5.2を使用しています。行のXの平均値の双曲線正接が0.15以上である場合、私は「死んだ」という文字列である新しい列を定義したい。ここから他の列の平均でパンダの条件付き列
#Make Synthetic data (great again?)
#synth X
data=pd.DataFrame(np.random.randn(100,5), columns= 'x1','x2','x3','x4','x5'])
def div10(x):
if x<0:
return -x/5
else:
return x/10
data=data.applymap(div10)
と:私はそうと、それを定義することによって開始します「そう生きている:私はnp.tanh(data.mean(axis=1))>.15
をチェックすると、私はValueError: ('The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().', 'occurred at index 0')
聞いてい
data['Y']=data.apply(lambda x:'dead' if np.tanh(data.mean(axis=1))>.15 else 'alive',axis=1)
私はboolsのリストを取得します。
私はまた、マップを試してみましたが、AttributeError: 'DataFrame' object has no attribute 'map'
は平均関数からそんなに –