作者threepoint (阿毛)
看板Python
標題[問題] 請問dataframe怎麼用變數替換欄位
時間Mon Sep 20 11:37:56 2021
舉例pd如下
0056 0050
2021/01/01 33 130
2021/01/02 34 131
想要用for依序抓取0056 & 0050
pd = pd["0056"] 這邊的0056怎麼用變數取代, 感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.243.28.144 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1632109078.A.DD6.html
→ Cochran: df.columns? 09/20 11:58
推 camphor0614: 可以考慮用dataframe.iloc,用index number去抓 09/20 12:03
→ chickengod: 盡量不要在pandas 使用 for loop 09/20 16:35
→ chickengod: 隨著row 和column數目增加 執行時間差很大 09/20 16:35
→ threepoint: 感謝各位大大 09/21 11:18