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

  • <small id='7XSBo'></small><noframes id='7XSBo'>

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

        阻止 Pandas 將 int 轉(zhuǎn)換為 float

        Stop Pandas from converting int to float(阻止 Pandas 將 int 轉(zhuǎn)換為 float)

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

          <legend id='P5I8F'><style id='P5I8F'><dir id='P5I8F'><q id='P5I8F'></q></dir></style></legend>
        1. <small id='P5I8F'></small><noframes id='P5I8F'>

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

                <tbody id='P5I8F'></tbody>
                1. 本文介紹了阻止 Pandas 將 int 轉(zhuǎn)換為 float的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我有一個(gè) DataFrame.以下是兩個(gè)相關(guān)的列:一個(gè)是 int 的列,另一個(gè)是 str 的列.

                  I have a DataFrame. Two relevant columns are the following: one is a column of int and another is a column of str.

                  我知道如果我將 NaN 插入 int 列,Pandas 會(huì)將所有 int 轉(zhuǎn)換為 float 因?yàn)?int 沒(méi)有 NaN 值.

                  I understand that if I insert NaN into the int column, Pandas will convert all the int into float because there is no NaN value for an int.

                  但是,當(dāng)我將 None 插入 str 列時(shí),Pandas 會(huì)將我的所有 int 轉(zhuǎn)換為 float 為好.這對(duì)我來(lái)說(shuō)沒(méi)有意義 - 為什么我在第 2 列中輸入的值會(huì)影響第 1 列?

                  However, when I insert None into the str column, Pandas converts all my int to float as well. This doesn't make sense to me - why does the value I put in column 2 affect column 1?

                  這是一個(gè)簡(jiǎn)單的工作示例(Python 2):

                  Here's a simple working example (Python 2):

                  import pandas as pd
                  df = pd.DataFrame()
                  df["int"] = pd.Series([], dtype=int)
                  df["str"] = pd.Series([], dtype=str)
                  df.loc[0] = [0, "zero"]
                  print df
                  print
                  df.loc[1] = [1, None]
                  print df
                  

                  輸出是

                     int   str
                  0    0  zero
                  
                     int   str
                  0  0.0  zero
                  1  1.0   NaN
                  

                  有沒(méi)有辦法讓輸出如下:

                  Is there any way to make the output the following:

                     int   str
                  0    0  zero
                  
                     int   str
                  0    0  zero
                  1    1   NaN
                  

                  不將第一列重鑄為 int.

                  • 我更喜歡使用 int 而不是 float 因?yàn)閷?shí)際數(shù)據(jù)在該列是整數(shù).如果沒(méi)有解決方法,我只會(huì)使用 float.

                  • I prefer using int instead of float because the actual data in that column are integers. If there's not workaround, I'll just use float though.

                  我不喜歡重鑄,因?yàn)樵谖业膶?shí)際代碼中,我不需要
                  存儲(chǔ)實(shí)際的dtype.

                  I prefer not having to recast because in my actual code, I don't
                  store the actual dtype.

                  我還需要逐行插入數(shù)據(jù).

                  I also need the data inserted row-by-row.

                  推薦答案

                  如果你設(shè)置dtype=object,你的系列就可以包含任意數(shù)據(jù)類(lèi)型:

                  If you set dtype=object, your series will be able to contain arbitrary data types:

                  df["int"] = pd.Series([], dtype=object)
                  df["str"] = pd.Series([], dtype=str)
                  df.loc[0] = [0, "zero"]
                  print(df)
                  print()
                  df.loc[1] = [1, None]
                  print(df)
                  
                     int   str
                  0    0  zero
                  1  NaN   NaN
                  
                    int   str
                  0   0  zero
                  1   1  None
                  

                  這篇關(guān)于阻止 Pandas 將 int 轉(zhuǎn)換為 float的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個(gè)模塊和類(lèi))
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點(diǎn)包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復(fù)導(dǎo)入頂級(jí)名稱(chēng)的情況下構(gòu)造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發(fā)帶有已編譯動(dòng)態(tài)共享庫(kù)的 Python 包)

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

                          <tbody id='ndg5s'></tbody>
                        <legend id='ndg5s'><style id='ndg5s'><dir id='ndg5s'><q id='ndg5s'></q></dir></style></legend>

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

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

                            主站蜘蛛池模板: 日韩喷潮| 亚洲91精品 | 三级在线视频 | 亚洲精品久久 | 国产精品亚洲一区二区三区在线观看 | 亚洲欧洲中文日韩 | 91精品国产乱码久久久久久 | 国产熟熟 | 偷拍第一页 | 一区免费视频 | 国产精品毛片一区二区在线看 | 国产高清在线视频 | 日韩不卡视频在线观看 | 精品久久久久久久久久 | 看av网址| 国产一区二区欧美 | 精品国产99| 欧美成人一区二区三区 | 欧美黑人激情 | 亚洲欧洲成人av每日更新 | 视频二区 | 久久久高清 | 日韩久久久久久久久久久 | 日韩欧美在线播放 | 国产一区二区在线播放 | 国产精品色婷婷久久58 | 久久天堂网 | 国产精品视频免费播放 | 久在线视频 | www.久久久.com | 超碰男人天堂 | 色视频网站免费 | 免费看的黄网站 | 国产精品成人在线播放 | 国产日韩一区二区三区 | 亚洲成人免费 | 国产美女高潮 | 亚洲一区二区三区四区五区中文 | 日韩欧美一区二区三区免费观看 | 精品熟人一区二区三区四区 | 欧美视频免费在线观看 |