import
pandas as pd
import
numpy as np
NaN
=
np.nan
____10=
>>> df.count[] Person 5 Age 4 Single 5 dtype: int642
>>> df.count[] Person 5 Age 4 Single 5 dtype: int643
>>> df.count[] Person 5 Age 4 Single 5 dtype: int644
>>> df.count[] Person 5 Age 4 Single 5 dtype: int645
>>> df.count[] Person 5 Age 4 Single 5 dtype: int646
>>> df.count[] Person 5 Age 4 Single 5 dtype: int647
>>> df.count[] Person 5 Age 4 Single 5 dtype: int648
>>> df.count[] Person 5 Age 4 Single 5 dtype: int649
>>> df.count[axis='columns'] 0 3 1 2 2 3 3 3 4 3 dtype: int640
>>> df.count[] Person 5 Age 4 Single 5 dtype: int646
>>> df.count[axis='columns'] 0 3 1 2 2 3 3 3 4 3 dtype: int642
>>> df.count[] Person 5 Age 4 Single 5 dtype: int648
>>> df.count[] Person 5 Age 4 Single 5 dtype: int649
>>> df.count[axis='columns'] 0 3 1 2 2 3 3 3 4 3 dtype: int645
>>> df.count[] Person 5 Age 4 Single 5 dtype: int646
>>> df.count[] Person 5 Age 4 Single 5 dtype: int645
>>> df.count[axis='columns'] 0 3 1 2 2 3 3 3 4 3 dtype: int648
>>> df.count[axis='columns'] 0 3 1 2 2 3 3 3 4 3 dtype: int649
import
0>>> df.count[] Person 5 Age 4 Single 5 dtype: int644
import
2>>> df.count[] Person 5 Age 4 Single 5 dtype: int646
import
4>>> df.count[] Person 5 Age 4 Single 5 dtype: int646
import
6>>> df.count[] Person 5 Age 4 Single 5 dtype: int646
import
8import
9import
2>>> df.count[axis='columns'] 0 3 1 2 2 3 3 3 4 3 dtype: int648
Các
>>> df.count[axis='columns'] 0 3 1 2 2 3 3 3 4 3 dtype: int649
import
6>>> df.count[] Person 5 Age 4 Single 5 dtype: int644
import
6>>> df.count[] Person 5 Age 4 Single 5 dtype: int646
pandas as pd
5>>> df.count[] Person 5 Age 4 Single 5 dtype: int646
numpy as np
2numpy as np
3import
6numpy as np
5numpy as np
6numpy as np
7numpy as np
8numpy as np
9
numpy as np
6NaN
1
numpy as np
6numpy as np
7NaN
4numpy as np
9
numpy as np
6NaN
7
numpy as np
6numpy as np
7=
0numpy as np
9
numpy as np
6=
3=
=
5=
6
numpy as np
6=
3=
np.nan
0=
6
numpy as np
6numpy as np
7np.nan
4numpy as np
9
numpy as np
6np.nan
7np.nan
8np.nan
9
numpy as np
6numpy as np
7
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6402
>>> df.count[] Person 5 Age 4 Single 5 dtype: int648
‘
numpy as np
6numpy as np
7
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6412
>>> df.count[] Person 5 Age 4 Single 5 dtype: int648
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6404
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6415
import
0>>> df.count[] Person 5 Age 4 Single 5 dtype: int6417
import
2>>> df.count[] Person 5 Age 4 Single 5 dtype: int6419
>>> df.count[] Person 5 Age 4 Single 5 dtype: int643
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6421
numpy as np
6
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6423
import
0>>> df.count[] Person 5 Age 4 Single 5 dtype: int6417
import
2>>> df.count[] Person 5 Age 4 Single 5 dtype: int6427
numpy as np
6numpy as np
7
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6430
>>> df.count[] Person 5 Age 4 Single 5 dtype: int648
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6404
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6433
import
0>>> df.count[] Person 5 Age 4 Single 5 dtype: int6417
pandas as pd
5>>> df.count[] Person 5 Age 4 Single 5 dtype: int6437
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6438
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6439
pandas as pd
3>>> df.count[] Person 5 Age 4 Single 5 dtype: int6417
import
2>>> df.count[] Person 5 Age 4 Single 5 dtype: int6437
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6438
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6439
import
6>>> df.count[] Person 5 Age 4 Single 5 dtype: int6417
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6448
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6449
>>> df.count[] Person 5 Age 4 Single 5 dtype: int643
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6421
numpy as np
6
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6453
import
0>>> df.count[] Person 5 Age 4 Single 5 dtype: int6417
pandas as pd
5>>> df.count[] Person 5 Age 4 Single 5 dtype: int6437
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6438
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6439
pandas as pd
3>>> df.count[] Person 5 Age 4 Single 5 dtype: int6417
import
2>>> df.count[] Person 5 Age 4 Single 5 dtype: int6437
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6438
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6439
import
6>>> df.count[] Person 5 Age 4 Single 5 dtype: int6417
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6448
>>> df.count[] Person 5 Age 4 Single 5 dtype: int6469
Đếm các ô không NA cho mỗi cột hoặc hàng. Các giá trị không có, nan, nat và tùy chọn numpy.inf [tùy thuộc vào pandas.options.mode.use_inf_as_na] được coi là NA.
Nếu số lượng 0 hoặc ‘chỉ mục được tạo cho mỗi cột. Nếu số lượng 1 hoặc ‘cột được tạo cho mỗi hàng.
Cấp độ hoặc STR, tùy chọnint or str, optionalNếu trục là đa dạng [phân cấp], hãy tính theo một cấp độ cụ thể, sụp đổ thành một khung dữ liệu. Một str chỉ định tên cấp độ.
numeric_onlybool, mặc định saibool, default FalseChỉ bao gồm dữ liệu Float, Int hoặc Boolean.
ReturnSseries hoặc dataFrameĐối với mỗi cột/hàng, số lượng mục không NA/null. Nếu cấp độ được chỉ định, hãy trả về DataFrame.
Ví dụ
Xây dựng DataFrame từ một từ điển:
>>> df = pd.DataFrame[{"Person": ... ["John", "Myla", "Lewis", "John", "Myla"], ... "Age": [24., np.nan, 21., 33, 26], ... "Single": [False, True, True, True, False]}] >>> df Person Age Single 0 John 24.0 False 1 Myla NaN True 2 Lewis 21.0 True 3 John 33.0 True 4 Myla 26.0 False
Lưu ý các giá trị NA chưa được tính:
>>> df.count[] Person 5 Age 4 Single 5 dtype: int64
Đếm cho mỗi hàng:row:
>>> df.count[axis='columns'] 0 3 1 2 2 3 3 3 4 3 dtype: int64