久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <tfoot id='k8tSt'></tfoot>

      <i id='k8tSt'><tr id='k8tSt'><dt id='k8tSt'><q id='k8tSt'><span id='k8tSt'><b id='k8tSt'><form id='k8tSt'><ins id='k8tSt'></ins><ul id='k8tSt'></ul><sub id='k8tSt'></sub></form><legend id='k8tSt'></legend><bdo id='k8tSt'><pre id='k8tSt'><center id='k8tSt'></center></pre></bdo></b><th id='k8tSt'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='k8tSt'><tfoot id='k8tSt'></tfoot><dl id='k8tSt'><fieldset id='k8tSt'></fieldset></dl></div>
        <bdo id='k8tSt'></bdo><ul id='k8tSt'></ul>
        <legend id='k8tSt'><style id='k8tSt'><dir id='k8tSt'><q id='k8tSt'></q></dir></style></legend>
      1. <small id='k8tSt'></small><noframes id='k8tSt'>

      2. Pandas 將 csv 讀取為字符串類型

        Pandas reading csv as string type(Pandas 將 csv 讀取為字符串類型)

            <tbody id='e7ArV'></tbody>

          <i id='e7ArV'><tr id='e7ArV'><dt id='e7ArV'><q id='e7ArV'><span id='e7ArV'><b id='e7ArV'><form id='e7ArV'><ins id='e7ArV'></ins><ul id='e7ArV'></ul><sub id='e7ArV'></sub></form><legend id='e7ArV'></legend><bdo id='e7ArV'><pre id='e7ArV'><center id='e7ArV'></center></pre></bdo></b><th id='e7ArV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='e7ArV'><tfoot id='e7ArV'></tfoot><dl id='e7ArV'><fieldset id='e7ArV'></fieldset></dl></div>

            <small id='e7ArV'></small><noframes id='e7ArV'>

                  <bdo id='e7ArV'></bdo><ul id='e7ArV'></ul>
                • <tfoot id='e7ArV'></tfoot><legend id='e7ArV'><style id='e7ArV'><dir id='e7ArV'><q id='e7ArV'></q></dir></style></legend>

                • 本文介紹了Pandas 將 csv 讀取為字符串類型的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我有一個帶有字母數(shù)字鍵的數(shù)據(jù)框,我想將其保存為 csv 并稍后讀回.由于各種原因,我需要將此鍵列顯式讀取為字符串格式,我有嚴格數(shù)字的鍵,甚至更糟,例如:1234E5,Pandas 將其解釋為浮點數(shù).這顯然使密鑰完全無用.

                  I have a data frame with alpha-numeric keys which I want to save as a csv and read back later. For various reasons I need to explicitly read this key column as a string format, I have keys which are strictly numeric or even worse, things like: 1234E5 which Pandas interprets as a float. This obviously makes the key completely useless.

                  問題是,當(dāng)我為數(shù)據(jù)框或其任何列指定字符串 dtype 時,我只會得到垃圾.我這里有一些示例代碼:

                  The problem is when I specify a string dtype for the data frame or any column of it I just get garbage back. I have some example code here:

                  df = pd.DataFrame(np.random.rand(2,2),
                                    index=['1A', '1B'],
                                    columns=['A', 'B'])
                  df.to_csv(savefile)
                  

                  數(shù)據(jù)框如下:

                             A         B
                  1A  0.209059  0.275554
                  1B  0.742666  0.721165
                  

                  然后我是這樣讀的:

                  df_read = pd.read_csv(savefile, dtype=str, index_col=0)
                  

                  結(jié)果是:

                     A  B
                  B  (  <
                  

                  這是我的電腦問題,還是我在這里做錯了什么,或者只是一個錯誤?

                  Is this a problem with my computer, or something I'm doing wrong here, or just a bug?

                  推薦答案

                  更新:這有 已修復(fù):從 0.11.1 開始,您傳遞 str/np.str 將等同于使用 object.

                  Update: this has been fixed: from 0.11.1 you passing str/np.str will be equivalent to using object.

                  使用對象數(shù)據(jù)類型:

                  In [11]: pd.read_csv('a', dtype=object, index_col=0)
                  Out[11]:
                                        A                     B
                  1A  0.35633069074776547     0.745585398803751
                  1B  0.20037376323337375  0.013921830784260236
                  

                  或者更好,只是不要指定數(shù)據(jù)類型:

                  or better yet, just don't specify a dtype:

                  In [12]: pd.read_csv('a', index_col=0)
                  Out[12]:
                             A         B
                  1A  0.356331  0.745585
                  1B  0.200374  0.013922
                  

                  但是繞過類型嗅探器并真正返回 only 字符串需要使用 converters:

                  but bypassing the type sniffer and truly returning only strings requires a hacky use of converters:

                  In [13]: pd.read_csv('a', converters={i: str for i in range(100)})
                  Out[13]:
                                        A                     B
                  1A  0.35633069074776547     0.745585398803751
                  1B  0.20037376323337375  0.013921830784260236
                  

                  其中 100 是等于或大于您的總列數(shù)的某個數(shù)字.

                  where 100 is some number equal or greater than your total number of columns.

                  最好避免使用 str dtype,例如參見 這里.

                  這篇關(guān)于Pandas 將 csv 讀取為字符串類型的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動時,yaxis 刻度標簽應(yīng)該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                  • <legend id='XeGDj'><style id='XeGDj'><dir id='XeGDj'><q id='XeGDj'></q></dir></style></legend>

                      <tbody id='XeGDj'></tbody>
                      <tfoot id='XeGDj'></tfoot>

                            <bdo id='XeGDj'></bdo><ul id='XeGDj'></ul>

                            <small id='XeGDj'></small><noframes id='XeGDj'>

                            <i id='XeGDj'><tr id='XeGDj'><dt id='XeGDj'><q id='XeGDj'><span id='XeGDj'><b id='XeGDj'><form id='XeGDj'><ins id='XeGDj'></ins><ul id='XeGDj'></ul><sub id='XeGDj'></sub></form><legend id='XeGDj'></legend><bdo id='XeGDj'><pre id='XeGDj'><center id='XeGDj'></center></pre></bdo></b><th id='XeGDj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XeGDj'><tfoot id='XeGDj'></tfoot><dl id='XeGDj'><fieldset id='XeGDj'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 天天澡天天操 | 91视频官网 | 能看的av | 国产精品综合一区二区 | 女朋友的闺蜜3韩国三级 | 97人人爱| 一区日韩 | 亚洲成人免费视频在线观看 | 日韩精品在线一区 | 久久久久国产一区二区三区四区 | 在线欧美亚洲 | 精品久久久精品 | 国产精品片aa在线观看 | 午夜在线影院 | 中文一区 | 看片国产 | 成年人在线观看 | 波多野结衣精品 | 国产黄色免费网站 | 黄网址在线观看 | 精品日韩 | 密室大逃脱第六季大神版在线观看 | 日韩在线免费看 | 日韩欧美专区 | 国产极品车模吞精高潮呻吟 | 特黄特色大片免费视频观看 | 毛片久久久 | 丁香婷婷久久久综合精品国产 | 美国a级毛片免费视频 | 9191成人精品久久 | 国产精品自拍视频网站 | 中文字幕一区二区三区乱码在线 | 成人免费网站在线 | 欧美一区二区三区免费电影 | 日日干日日色 | 视频一区二区中文字幕 | 欧美在线日韩 | 久热爱| 精品久久久久久久 | 成人久久 | 99综合网 |