看板 Python 關於我們 聯絡資訊
在用pandas整理資料時發現 dataframe["column1"] = pd.to_numeric(dataframe["column1"]) dataframe["column2"] = pd.to_numeric(dataframe.column2 ) dataframe.column3 = pd.to_numeric(dataframe.column3 ) dataframe.column4 = pd.to_numeric(dataframe.["column4"]) 四種方式都可以將資料型態轉成數值。 想請問各位大大 dataframe.columndataframe["column"] 在使用上有什麼不一樣的地方? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.102.195.196 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1608790516.A.FB8.html
Hsins: 存取速度上來說沒什麼差別,但用 dot notation 需要額外注 12/24 15:12
Hsins: 意一些東西。第一個是當你欄位名稱含有空格或特殊字元時不 12/24 15:12
Hsins: 能使用 dot notation,另外就是這種存取方式不能拿來開新的 12/24 15:12
Hsins: 一欄 12/24 15:12
Hsins: https://youtu.be/LxZvl9Mc1cY 12/24 15:13
world4849844: 感謝 H大回答! 12/24 21:03
loser113: column name 有空格就不能用 . 的方式 01/20 15:32