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

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

如何將對(duì)熊貓數(shù)據(jù)框進(jìn)行分組操作后獲得的數(shù)據(jù)結(jié)構(gòu)轉(zhuǎn)換為數(shù)據(jù)框?

如何將對(duì)熊貓數(shù)據(jù)框進(jìn)行分組操作后獲得的數(shù)據(jù)結(jié)構(gòu)轉(zhuǎn)換為數(shù)據(jù)框?

函數(shù)式編程 2021-05-14 19:46:16
說我有從示例數(shù)據(jù)集在這里:import pandas as pdraw_data = {'regiment': ['Nighthawks', 'Nighthawks', 'Nighthawks', 'Nighthawks', 'Dragoons', 'Dragoons', 'Dragoons', 'Dragoons', 'Scouts', 'Scouts', 'Scouts', 'Scouts'],         'company': ['1st', '1st', '2nd', '2nd', '1st', '1st', '2nd', '2nd','1st', '1st', '2nd', '2nd'],         'name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze', 'Jacon', 'Ryaner', 'Sone', 'Sloan', 'Piger', 'Riani', 'Ali'],         'preTestScore': [4, 24, 31, 2, 3, 4, 24, 31, 2, 3, 2, 3],        'postTestScore': [25, 94, 57, 62, 70, 25, 94, 57, 62, 70, 62, 70]}df = pd.DataFrame(raw_data, columns = ['regiment', 'company', 'name', 'preTestScore', 'postTestScore'])df我想做一個(gè)regimentvs的箱線圖preTestScore。為此,我需要找出這兩個(gè)變量的相對(duì)分布。所以,我regiment按preTestScore以下方式分組:df1 = df['regiment'].groupby(df['preTestScore']).count()df1preTestScore2     33     34     224    231    2Name: regiment, dtype: int64
查看完整描述

1 回答

?
幕布斯7119047

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

使用to_frame該系列轉(zhuǎn)換成數(shù)據(jù)幀,然后繪制之前重置索引:

df1 = df['regiment'].groupby(df['preTestScore']).count().to_frame().reset_index()
sns.boxplot(x='regiment', y='preTestScore', data=df1)


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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