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

      <tfoot id='NCEMx'></tfoot>

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

      <i id='NCEMx'><tr id='NCEMx'><dt id='NCEMx'><q id='NCEMx'><span id='NCEMx'><b id='NCEMx'><form id='NCEMx'><ins id='NCEMx'></ins><ul id='NCEMx'></ul><sub id='NCEMx'></sub></form><legend id='NCEMx'></legend><bdo id='NCEMx'><pre id='NCEMx'><center id='NCEMx'></center></pre></bdo></b><th id='NCEMx'></th></span></q></dt></tr></i><div id='NCEMx'><tfoot id='NCEMx'></tfoot><dl id='NCEMx'><fieldset id='NCEMx'></fieldset></dl></div>
    1. <legend id='NCEMx'><style id='NCEMx'><dir id='NCEMx'><q id='NCEMx'></q></dir></style></legend>
      1. Python Pandas 数据框查找缺失值

        Python Pandas dataframe find missing values(Python Pandas 数据框查找缺失值)

        <tfoot id='x5R1i'></tfoot>

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

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

            1. <i id='x5R1i'><tr id='x5R1i'><dt id='x5R1i'><q id='x5R1i'><span id='x5R1i'><b id='x5R1i'><form id='x5R1i'><ins id='x5R1i'></ins><ul id='x5R1i'></ul><sub id='x5R1i'></sub></form><legend id='x5R1i'></legend><bdo id='x5R1i'><pre id='x5R1i'><center id='x5R1i'></center></pre></bdo></b><th id='x5R1i'></th></span></q></dt></tr></i><div id='x5R1i'><tfoot id='x5R1i'></tfoot><dl id='x5R1i'><fieldset id='x5R1i'></fieldset></dl></div>
                <tbody id='x5R1i'></tbody>
                • 本文介绍了Python Pandas 数据框查找缺失值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试查找缺失值,然后删除缺失值.尝试在线查找数据,但似乎找不到答案.

                  提取的数据框:

                  在 df 中,对于 1981 年和 1982 年,它应该是 '-',即缺失值.我想找到缺失值,然后删除缺失值.

                  使用 isnull 导出的数据框:

                  我使用了 df.isnull() 但在 1981 年和 1982 年,它被检测为假",这意味着有数据.但它应该是'-',因此被认为是缺失值.

                  我在下面粘贴了我的代码.我错过了什么?

                  将 pandas 导入为 pdmydf = pd.read_excel('abc.xlsx', sep='	')df1 = mydf.set_index('变量')df = df1[0:10]打印(df)打印(df.isnull())

                  解决方案

                  问题有两点:找出哪些列有缺失值并删除那些值.

                  在数据帧上查找缺失值 df

                  缺失 = df.isnull().sum()打印(缺失)

                  要删除这些缺失值,除了@jezrael 的考虑之外,如果这没有帮助,我建议您使用 dropna:

                  <块引用>

                  删除所有元素都缺失的行.

                  df.dropna(how='all')

                  <块引用>

                  删除至少缺少一个元素的列.

                  df.dropna(axis='columns')

                  I'm trying to find missing values and then drop off missing values. Tried looking for the data online but can't seem to find the answer.

                  Extracted Dataframe:

                  In the df, for 1981 and 1982, it should be '-', i.e. missing values. I would like to find the missing values then drop off the missing values.

                  Exported Dataframe using isnull:

                  I used df.isnull() but in 1981 and 1982, it's detected as 'False' which means there's data. But it should be '-', therefore considered as missing values.

                  I had pasted my code below. What am I missing out?

                  import pandas as pd
                  
                  mydf = pd.read_excel('abc.xlsx', sep='	')
                  
                  df1 = mydf.set_index('Variables')
                  df = df1[0:10]
                  print(df)
                  print(df.isnull())
                  

                  解决方案

                  The question has two points: finding which columns have missing values and drop those values.

                  To find the missing values on a dataframe df

                  missing = df.isnull().sum()
                  print(missing)
                  

                  To drop those missing values, apart from @jezrael's consideration, if that doesn't help, I suggest you to use dropna:

                  Drop the rows where all elements are missing.

                  df.dropna(how='all')
                  

                  Drop the columns where at least one element is missing.

                  df.dropna(axis='columns')
                  

                  这篇关于Python Pandas 数据框查找缺失值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                  <tfoot id='GhKGF'></tfoot>
                      <tbody id='GhKGF'></tbody>

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

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

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