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

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

熊貓?jiān)谘h(huán)中選擇下一列標(biāo)題

熊貓?jiān)谘h(huán)中選擇下一列標(biāo)題

SMILET 2023-05-23 16:47:32
我試圖在循環(huán)遍歷 pandas 數(shù)據(jù)框的列時(shí)訪問(wèn)下一列標(biāo)題。for cols in data.columns:     if data.columns.get_loc(cols) < len(data.columns):  # skip last column of data         count = data.groupby([cols, cols+1]).size()  # create new df and how many times the two columns occur但是cols+1給我一個(gè)錯(cuò)誤。這是因?yàn)閏ols返回標(biāo)題名稱(chēng),所以你不能 +1 一個(gè)字符串,但是在這樣的循環(huán)中獲取下一列標(biāo)題的最佳方法是什么?
查看完整描述

2 回答

?
慕田峪4524236

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

您可以枚舉列

for col_index, cols in enumerate(data.columns): 
   if col_index+1 < len(data.columns):  # skip last column of data
        count = data.groupby([cols,data.columns[col_index+1]]).size()  # create new df and how many times the two columns occur



查看完整回答
反對(duì) 回復(fù) 2023-05-23
?
長(zhǎng)風(fēng)秋雁

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

for col_idx in range(len(data.columns)-1):
    if data.columns.get_loc(data.columns[col_idx]) < len(data.columns): 
        count = data.groupby([col_idx, col_idx+1]).size()


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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