第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

串聯(lián)多個(gè)數(shù)據(jù)框并在DataFrame中對(duì)行進(jìn)行排序

串聯(lián)多個(gè)數(shù)據(jù)框并在DataFrame中對(duì)行進(jìn)行排序

不負(fù)相思意 2021-05-13 13:17:55
我需要合并多個(gè)數(shù)據(jù)框。這是數(shù)據(jù)幀的示例代碼df1 = pd.DataFrame(np.array([    [0, 5, 9],    [0.3434, 4, 61],    [10.22, 24, 9]]),    columns=['time', 'attr11', 'attr12'])df2 = pd.DataFrame(np.array([    [0, 5, 19],    [0.3, 14, 16],    [9.99, 4, 9]]),    columns=['time', 'attr21', 'attr22'])df3 = pd.DataFrame(np.array([    [0, 15, 49],    [6.66, 4, 36],    [9.66, 14, 9]]),    columns=['time', 'attr31', 'attr32'])現(xiàn)在,如果可以,請(qǐng)串聯(lián)con = pd.concat([df1,df2,df3], ignore_index=True, sort=True)sorted_data = con.sort_values(by="time")我得到的(幾乎)輸出是我想要的,但是還有3行0。這是我得到的輸出attr11  attr12  attr21  attr22  attr31  attr32  time0   5.0 9.0 NaN NaN NaN NaN 0.00003   NaN NaN 5.0 19.0    NaN NaN 0.00006   NaN NaN NaN NaN 15.0    49.0    0.00004   NaN NaN 14.0    16.0    NaN NaN 0.30001   4.0 61.0    NaN NaN NaN NaN 0.34347   NaN NaN NaN NaN 4.0 36.0    6.66008   NaN NaN NaN NaN 14.0    9.0 9.66005   NaN NaN 4.0 9.0 NaN NaN 9.99002   24.0    9.0 NaN NaN NaN NaN 10.2200零時(shí)間行應(yīng)具有一行,而不是三行,因此NaN零時(shí)間行中將沒有行。這應(yīng)該第一行看起來像0  5.0  9.0 5.0 19.0 15.0 49我怎樣才能做到這一點(diǎn) ?
查看完整描述

2 回答

?
三國紛爭(zhēng)

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊

這應(yīng)該工作。


aggregation_functions = {'attr11':'sum','attr12':'sum','attr21':'sum','attr22':'sum','attr31':'sum','attr32':'sum'}

con_new = con.groupby(con['time']).aggregate(aggregation_functions)

con_new


查看完整回答
反對(duì) 回復(fù) 2021-05-18
  • 2 回答
  • 0 關(guān)注
  • 208 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)