作者yshihyu (yshihyu)
看板Python
標題[問題] pandas 欄位拷貝跟刪除問題
時間Sun Jan 22 22:44:40 2017
我主要遇到問題是 pandas 表格 columns 欄位拷貝後會連同index數值也拷貝到columns
還有用類似字串切片方式 table index會變得不正確,
https://gist.github.com/anonymous/655f0a449970f5f01829d8fd79309a46
上面是我pandas 操作的問題描述, 因為在板上排版格式會跑掉也很亂所以放上面網址
https://gist.github.com/anonymous/581b16a5d07746cc39cd4e46ad0a950f
上面是我的程式碼
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 112.105.250.241
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1485096286.A.97F.html
→ yjc1: 1. df2.columns.name = '' 01/23 01:19
→ yjc1: 2. df2.drop(df2.index[0]); df2.index = range(len(df2)) 01/23 01:23
→ yjc1: 不過總覺得你的要求有點怪… 01/23 01:24
推 exthrash: reset_index? 01/23 06:40
推 aweimeow: 我剛開始碰 pandas 也和你有相同的疑問 01/23 22:43
→ aweimeow: 不過後來都是用 item iter 的方式就無關 index 的事情了 01/23 22:43
→ yshihyu: item iter 的方式是指像下面網址用法嘛? 01/24 23:16