怎么在pandas中使用read_table讀取csv文件?相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。
創(chuàng)新互聯公司是一家集做網站、網站建設、網站頁面設計、網站優(yōu)化SEO優(yōu)化為一體的專業(yè)的建站公司,已為成都等多地近百家企業(yè)提供網站建設服務。追求良好的瀏覽體驗,以探求精品塑造與理念升華,設計最適合用戶的網站頁面。 合作只是第一步,服務才是根本,我們始終堅持講誠信,負責任的原則,為您進行細心、貼心、認真的服務,與眾多客戶在蓬勃發(fā)展的市場環(huán)境中,互促共生。查看csv文件的內容如下;
In [10]: cat data.csv index,name,comment,,,, 1,name_01,coment_01,,,, 2,name_02,coment_02,,,, 3,name_03,coment_03,,,, 4,name_04,coment_04,,,, 5,name_05,coment_05,,,, 6,name_06,coment_06,,,, 7,name_07,coment_07,,,, 8,name_08,coment_08,,,, 9,name_09,coment_09,,,, 10,name_10,coment_10,,,, 11,name_11,coment_11,,,, 12,name_12,coment_12,,,, 13,name_13,coment_13,,,, 14,name_14,coment_14,,,, 15,name_15,coment_15,,,, 16,name_16,coment_16,,,, 17,name_17,coment_17,,,, 18,name_18,coment_18,,,, 19,name_19,coment_19,,,, 20,name_20,coment_20,,,, 21,name_21,coment_21,,,,
使用pandas讀取文件內容如下:In [11]: data1 = pd.read_table('data.csv',sep=',')
In [12]: type(data1) Out[12]: pandas.core.frame.DataFrame
In [13]: data1 Out[13]: index name comment Unnamed: 3 Unnamed: 4 Unnamed: 5 Unnamed: 6 0 1 name_01 coment_01 NaN NaN NaN NaN 1 2 name_02 coment_02 NaN NaN NaN NaN 2 3 name_03 coment_03 NaN NaN NaN NaN 3 4 name_04 coment_04 NaN NaN NaN NaN 4 5 name_05 coment_05 NaN NaN NaN NaN 5 6 name_06 coment_06 NaN NaN NaN NaN 6 7 name_07 coment_07 NaN NaN NaN NaN 7 8 name_08 coment_08 NaN NaN NaN NaN 8 9 name_09 coment_09 NaN NaN NaN NaN 9 10 name_10 coment_10 NaN NaN NaN NaN 10 11 name_11 coment_11 NaN NaN NaN NaN 11 12 name_12 coment_12 NaN NaN NaN NaN 12 13 name_13 coment_13 NaN NaN NaN NaN 13 14 name_14 coment_14 NaN NaN NaN NaN 14 15 name_15 coment_15 NaN NaN NaN NaN 15 16 name_16 coment_16 NaN NaN NaN NaN 16 17 name_17 coment_17 NaN NaN NaN NaN 17 18 name_18 coment_18 NaN NaN NaN NaN 18 19 name_19 coment_19 NaN NaN NaN NaN 19 20 name_20 coment_20 NaN NaN NaN NaN 20 21 name_21 coment_21 NaN NaN NaN NaN
不過在幾番嘗試下來,發(fā)現這個分隔符缺省的時候倒是也能夠讀出數據。
In [16]: data2 = pd.read_table('data.csv')
In [17]: data2 Out[17]: index,name,comment,,,, 0 1,name_01,coment_01,,,, 1 2,name_02,coment_02,,,, 2 3,name_03,coment_03,,,, 3 4,name_04,coment_04,,,, 4 5,name_05,coment_05,,,, 5 6,name_06,coment_06,,,, 6 7,name_07,coment_07,,,, 7 8,name_08,coment_08,,,, 8 9,name_09,coment_09,,,, 9 10,name_10,coment_10,,,, 10 11,name_11,coment_11,,,, 11 12,name_12,coment_12,,,, 12 13,name_13,coment_13,,,, 13 14,name_14,coment_14,,,, 14 15,name_15,coment_15,,,, 15 16,name_16,coment_16,,,, 16 17,name_17,coment_17,,,, 17 18,name_18,coment_18,,,, 18 19,name_19,coment_19,,,, 19 20,name_20,coment_20,,,, 20 21,name_21,coment_21,,,,
看完上述內容,你們掌握怎么在pandas中使用read_table讀取csv文件的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注創(chuàng)新互聯行業(yè)資訊頻道,感謝各位的閱讀!
標題名稱:怎么在pandas中使用read_table讀取csv文件-創(chuàng)新互聯
轉載來于:http://jinyejixie.com/article14/dpoige.html
成都網站建設公司_創(chuàng)新互聯,為您提供網站改版、網站設計、定制開發(fā)、外貿建站、網站建設、營銷型網站建設
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯