Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 689077d

Browse files
authored
correct doc for DF.count (#683)
1 parent 8fc958a commit 689077d

File tree

2 files changed

+79
-16
lines changed

2 files changed

+79
-16
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# *****************************************************************************
2+
# Copyright (c) 2020, Intel Corporation All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
#
10+
# Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
# *****************************************************************************
26+
27+
# result
28+
# A 4
29+
# B 4
30+
# C 3
31+
# dtype: int64
32+
33+
import pandas as pd
34+
import numpy as np
35+
from numba import njit
36+
37+
38+
@njit
39+
def dataframe_count():
40+
df = pd.DataFrame({"A": [.2, .0, .6, .2],
41+
"B": [2, 0, 6, 2],
42+
"C": [-1, np.nan, 1, np.inf]})
43+
44+
return df.count()
45+
46+
47+
print(dataframe_count())

sdc/datatypes/hpat_pandas_dataframe_functions.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,26 +1112,42 @@ def prod_overload(df, axis=None, skipna=None, level=None, numeric_only=None, min
11121112
@sdc_overload_method(DataFrameType, 'count')
11131113
def count_overload(df, axis=0, level=None, numeric_only=False):
11141114
"""
1115-
Pandas DataFrame method :meth:`pandas.DataFrame.count` implementation.
1116-
.. only:: developer
1115+
Intel Scalable Dataframe Compiler User Guide
1116+
********************************************
11171117
1118-
Test: python -m sdc.runtests -k sdc.tests.test_dataframe.TestDataFrame.test_count*
1118+
Pandas API: pandas.DataFrame.count
11191119
1120-
Parameters
1120+
Limitations
11211121
-----------
1122-
df: :class:`pandas.DataFrame`
1123-
input arg
1124-
axis:
1125-
*unsupported*
1126-
level:
1127-
*unsupported*
1128-
numeric_only:
1129-
*unsupported*
1122+
Parameters ``axis``, ``level`` and ``numeric_only`` are unsupported.
11301123
1131-
Returns
1132-
-------
1133-
:obj:`pandas.Series` or `pandas.DataFrame`
1134-
for each column/row the number of non-NA/null entries. If level is specified returns a DataFrame.
1124+
Examples
1125+
--------
1126+
.. literalinclude:: ../../../examples/dataframe/dataframe_count.py
1127+
:language: python
1128+
:lines: 33-
1129+
:caption: Count non-NA cells for each column or row.
1130+
:name: ex_dataframe_count
1131+
1132+
.. command-output:: python ./dataframe/dataframe_count.py
1133+
:cwd: ../../../examples
1134+
1135+
.. seealso::
1136+
:ref:`Series.count <pandas.Series.count>`
1137+
Number of non-NA elements in a Series.
1138+
:ref:`DataFrame.shape <pandas.DataFrame.shape>`
1139+
Number of DataFrame rows and columns (including NA elements).
1140+
:ref:`DataFrame.isna <pandas.DataFrame.isna>`
1141+
Boolean same-sized DataFrame showing places of NA elements.
1142+
1143+
Intel Scalable Dataframe Compiler Developer Guide
1144+
*************************************************
1145+
1146+
Pandas DataFrame method :meth:`pandas.DataFrame.count` implementation.
1147+
1148+
.. only:: developer
1149+
1150+
Test: python -m sdc.runtests -k sdc.tests.test_dataframe.TestDataFrame.test_count*
11351151
"""
11361152

11371153
name = 'count'

0 commit comments

Comments
 (0)