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

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

      <tfoot id='oTCqd'></tfoot>

    1. <small id='oTCqd'></small><noframes id='oTCqd'>

        pandas read_csv 列 dtype 設置為十進制但轉換為字符串

        pandas read_csv column dtype is set to decimal but converts to string(pandas read_csv 列 dtype 設置為十進制但轉換為字符串)
          <i id='nyvT3'><tr id='nyvT3'><dt id='nyvT3'><q id='nyvT3'><span id='nyvT3'><b id='nyvT3'><form id='nyvT3'><ins id='nyvT3'></ins><ul id='nyvT3'></ul><sub id='nyvT3'></sub></form><legend id='nyvT3'></legend><bdo id='nyvT3'><pre id='nyvT3'><center id='nyvT3'></center></pre></bdo></b><th id='nyvT3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nyvT3'><tfoot id='nyvT3'></tfoot><dl id='nyvT3'><fieldset id='nyvT3'></fieldset></dl></div>
          <legend id='nyvT3'><style id='nyvT3'><dir id='nyvT3'><q id='nyvT3'></q></dir></style></legend>
          1. <small id='nyvT3'></small><noframes id='nyvT3'>

            <tfoot id='nyvT3'></tfoot>

                <tbody id='nyvT3'></tbody>

                • <bdo id='nyvT3'></bdo><ul id='nyvT3'></ul>

                  本文介紹了pandas read_csv 列 dtype 設置為十進制但轉換為字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 pandas (v0.18.1) 從名為test.csv"的文件中導入以下數據:

                  I am using pandas (v0.18.1) to import the following data from a file called 'test.csv':

                  a,b,c,d
                  1,1,1,1.0
                  

                  我已將列 'c' 和 'd' 的 dtype 設置為 'decimal.Decimal' 但它們返回為類型 'str'.

                  I have set the dtype to 'decimal.Decimal' for columns 'c' and 'd' but instead they return as type 'str'.

                  import pandas as pd
                  import decimal as D
                  
                  df = pd.read_csv('test.csv', dtype={'a': int, 'b': float, 'c': D.Decimal, 'd': D.Decimal})
                  
                  for i, v in df.iterrows():
                      print(type(v.a), type(v.b), type(v.c), type(v.d))
                  

                  結果:

                  `<class 'int'> <class 'float'> <class 'str'> <class 'str'>`
                  

                  我還嘗試在導入后顯式轉換為十進制,但沒有成功(轉換為浮點有效但不是十進制).

                  I have also tried converting to decimal explicitly after import with no luck (converting to float works but not decimal).

                  df.c = df.c.astype(float)
                  df.d = df.d.astype(D.Decimal)
                  for i, v in df.iterrows():
                      print(type(v.a), type(v.b), type(v.c), type(v.d))
                  

                  結果:

                  `<class 'int'> <class 'float'> <class 'float'> <class 'str'>`
                  

                  以下代碼將str"轉換為decimal.Decimal",所以我不明白為什么 pandas 的行為方式不同.

                  The following code converts a 'str' to 'decimal.Decimal' so I don't understand why pandas doesn't behave the same way.

                  x = D.Decimal('1.0')
                  print(type(x))
                  

                  結果:

                  `<class 'decimal.Decimal'>`
                  

                  推薦答案

                  我覺得你需要轉換器:

                  import pandas as pd
                  import io
                  import decimal as D
                  
                  temp = u"""a,b,c,d
                             1,1,1,1.0"""
                  
                  # after testing replace io.StringIO(temp) to filename
                  df = pd.read_csv(io.StringIO(temp), 
                                   dtype={'a': int, 'b': float}, 
                                   converters={'c': D.Decimal, 'd': D.Decimal})
                  
                  print (df)
                         a    b  c    d
                      0  1  1.0  1  1.0
                  
                  for i, v in df.iterrows():
                      print(type(v.a), type(v.b), type(v.c), type(v.d))
                  
                      <class 'int'> <class 'float'> <class 'decimal.Decimal'> <class 'decimal.Decimal'>
                  

                  這篇關于pandas read_csv 列 dtype 設置為十進制但轉換為字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 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 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)

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

                        <tfoot id='O9DFO'></tfoot>

                      3. <small id='O9DFO'></small><noframes id='O9DFO'>

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

                            <tbody id='O9DFO'></tbody>
                            主站蜘蛛池模板: 久久久xx | 亚洲精品久久久久久久久久吃药 | 久久机热 | 国产区精品 | 日韩av在线一区 | 亚洲人成人一区二区在线观看 | av一区二区三区四区 | 午夜久草 | 欧美激情久久久 | 成人亚洲在线 | 黄色片a级 | 亚洲国产成人精品久久 | 国产成人精品一区二区三区在线 | www.操.com | 在线免费观看视频你懂的 | 国产黄色在线观看 | 日韩精品区| 国产激情91久久精品导航 | 久久精品91 | 成人精品一区二区 | 亚洲精品在线免费看 | h视频在线观看免费 | 日本成人免费网站 | 国产视频精品在线观看 | 中文字幕在线观看www | 人人干免费| 日本三级网站在线 | 久久亚| 国产天堂| 亚洲精品一区二区三区免 | 亚洲第一天堂 | 有码在线 | 日韩国产一区二区三区 | 黄色骚片 | 青久草视频 | 精品视频免费 | 久久精品国产99国产精品亚洲 | 日韩视频在线观看一区二区 | 久久精品国产清自在天天线 | 精品一区二区在线观看 | av一级毛片|