Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么pandas在descripe方法中不显示11行,如何修复输出?_Python_Pandas_Data Analysis - Fatal编程技术网

Python 为什么pandas在descripe方法中不显示11行,如何修复输出?

Python 为什么pandas在descripe方法中不显示11行,如何修复输出?,python,pandas,data-analysis,Python,Pandas,Data Analysis,如何修复pandas.descripe()方法的输出 我正在对一个包含16084条记录的excel文件进行分析。当我运行pd.descibe()时,它会丢失11条记录,并显示14921个计数。帐户_的计数为14921,状态为_no_,应为14932。与州有关的账户数量为1152,两者合计应为16084。当我在列上使用内置的len()函数时,它会返回正确数量的16084条记录 代码如下: import pandas as pd import numpy as np address_with_ac

如何修复pandas.descripe()方法的输出

我正在对一个包含16084条记录的excel文件进行分析。当我运行pd.descibe()时,它会丢失11条记录,并显示14921个计数。帐户_的计数为14921,状态为_no_,应为14932。与州有关的账户数量为1152,两者合计应为16084。当我在列上使用内置的len()函数时,它会返回正确数量的16084条记录

代码如下:

import pandas as pd
import numpy as np

address_with_accounts = pd.read_excel('private document.xlsx', sheet_name = 'Sheet1')
accounts = address_with_accounts[['Account Name', 'Sold To Street', 'Sold To City', 'Sold To State/Province']]

accounts_with_no_state = accounts[accounts['Sold To State/Province'].isnull()]
accounts_with_state = accounts[accounts['Sold To State/Province'].notnull()]


#print(accounts_with_no_state.head())
print('\n-------------------------------------------------------------------\n')
print("number of accounts: ", len(accounts_with_no_state['Account Name']))
print(accounts_with_no_state.describe())
print('\n-------------------------------------------------------------------\n')


#print(accounts_with_state.head())
print('\n-------------------------------------------------------------------\n')
print("number of accounts: ",  len(accounts_with_state['Account Name']))
print(accounts_with_state.describe())
print('\n-------------------------------------------------------------------\n')
出于隐私考虑,顶部地址被划掉的输出:


编辑:记录在那里,并在不同的列下显示为正确的数字,而不是帐户名称列,这是我需要的重要信息。

您的“帐户名称”列可能包含
NaN
,这不包括在计数中。
accounts\u with\u no\u state=accounts[accounts]['sall To State/Province'].isnull()]
账户_State=accounts[accounts['sall To State/Province'].notnull()]
我试过
.notna()
应该去掉所有的NaN值。你认为我应该检查python类型
None
?@root我检查了
NaN
s的几种不同方法,然后我得到了0。
print(“NaN的数量:”,len(没有状态的帐户[帐户名]='NaN'])
Try
accounts['Account'].isnull().sum()
以获取计数。您无法直接与
NaN
进行比较。非常感谢,我们得到了缺失的11个,我查看代码太久了,我没有意识到我查看的列是错误的
。notnull