0
我已經劃分一個數據幀:大熊貓,分組和彙總
rwp_initial.df.loc[rwp_initial.df.sample_name=='sma_initial'].groupby(by=['sample_name','pH','salt','column'])['concentration'].plot(marker = 'o', rot=30)
,並得到下面的輸出:
sample_name pH salt column
sma_initial 5.7 50 5 Axes(0.125,0.125;0.775x0.775)
6 Axes(0.125,0.125;0.775x0.775)
100 7 Axes(0.125,0.125;0.775x0.775)
8 Axes(0.125,0.125;0.775x0.775)
200 9 Axes(0.125,0.125;0.775x0.775)
10 Axes(0.125,0.125;0.775x0.775)
400 11 Axes(0.125,0.125;0.775x0.775)
12 Axes(0.125,0.125;0.775x0.775)
我想借此每個pH值和鹽內的平均濃度。這些列只是測量兩次的相同樣本。如果我使用aggregate(np.mean)
,則計算一列所有數據點的平均值。
這個數字也許凸顯了數據點我想借的(我想沿着行平均)平均:
rwp_initial.df.loc[rwp_initial.df.sample_name=='sma_initial'].groupby(by=['sample_name','pH','salt'])['concentration'].plot(marker = 'o', rot=30)