count( )
-
Pandas中count( )方法如何使用
Pandas中的count()方法用于计算DataFrame中非空值的数量。使用方法如下:,,“python,import pandas as pd,,# 创建一个DataFrame,data = {‘A’: [1, 2, None, 4], ‘B’: [None, 2, 3, 4]},df = pd.DataFrame(data),,# 使用count()方法,result = df.count(),print(result),`,,输出结果为:,,`,A 3,B 3,dtype: int64,“