[問題]有辦法解決index太多無法存入pdframe嗎?

看板Python作者 (pl132)時間3年前 (2022/05/13 18:30), 3年前編輯推噓3(301)
留言4則, 2人參與, 3年前最新討論串1/1
各位版上大大好 小弟最近在學習大數據分類 有個資料集我在使用Groudby分類之後出現雙重索引,在我使用pivot function把兩個索引 一個變index一個變column的時候會跳錯 由於小弟才疏學淺,一直找不到解法,不知道各位大大有遇過這樣的經驗嗎? 下面是錯誤訊息: RuntimeWarning: overflow encountered in long_scalars num_cells = num_rows * num_columns Exception "unhandled IndexError" index 1579266012 is out of bounds for axis 0 with size 1579249988 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.177.1.144 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1652437842.A.CED.html

05/13 19:01, 3年前 , 1F
別pivot, 資料重複會缺損都會error
05/13 19:01, 1F
但是我用以下方式也是跳錯 two_level_index_series = df.set_index(["姓名", "科目"])["分數"] 都會跳出索引不夠....series的時候就不會跳錯= = ※ 編輯: pl132 (180.177.1.144 臺灣), 05/13/2022 19:04:30 ※ 編輯: pl132 (180.177.1.144 臺灣), 05/13/2022 19:05:03

05/13 19:10, 3年前 , 2F
都可以完整讀取dataframe怎麼會索引不夠.
05/13 19:10, 2F
※ 編輯: pl132 (180.177.1.144 臺灣), 05/13/2022 19:57:16 #df3.pivot(index='User-ID', columns='ISBN', values='Book-Rating') 我是下了這行要再轉到新的pdframe就跳錯 ※ 編輯: pl132 (180.177.1.144 臺灣), 05/13/2022 19:57:51

05/13 23:25, 3年前 , 3F
先downcast一下
05/13 23:25, 3F

05/14 00:26, 3年前 , 4F
問A答B,這麼執著用pivot...也只能祝福了
05/14 00:26, 4F
我只是說那兩個方法都會類似錯誤啦= =我倒沒有一定要用pivot ※ 編輯: pl132 (180.177.1.144 臺灣), 05/14/2022 16:59:56
文章代碼(AID): #1YVZDIpj (Python)
文章代碼(AID): #1YVZDIpj (Python)