[問題] dataframe指定index_col取值問題

看板Python作者 (Talent)時間2年前 (2021/08/11 21:05), 編輯推噓2(203)
留言5則, 4人參與, 2年前最新討論串1/1
因為怕手機打字會造成程式碼與問題描述排版跑掉不方便閱讀,所以附上問題敘述圖片與程式碼、資料圖片,請大家幫忙或建議可能的方向,謝謝! 問題描述: https://i.imgur.com/syO9xmY.jpg
程式碼、dataframe資料: https://i.imgur.com/ZqXPFOT.jpg
----- Sent from JPTT on my iPhone -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.170.94.50 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1628687103.A.A15.html

08/11 22:12, 2年前 , 1F
df.isin 看看能不能解決你的問題
08/11 22:12, 1F

08/11 23:11, 2年前 , 2F
謝謝R大的資訊,我會再試試看!
08/11 23:11, 2F

08/12 07:57, 2年前 , 3F
df.loc[df.lo=='tw'].index.tolist()
08/12 07:57, 3F

08/12 11:51, 2年前 , 4F
df.loc["C",:] 你都設定name 當index了
08/12 11:51, 4F

08/12 20:04, 2年前 , 5F
C大的方法可行!我會再查資料熟悉df方法,感謝幫忙!
08/12 20:04, 5F
文章代碼(AID): #1X4yh_eL (Python)