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

Commit 1f64362

Browse files
authored
correct doc for DF.std (#692)
1 parent d2b3a07 commit 1f64362

2 files changed

Lines changed: 82 additions & 22 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
"""
28+
Expected result:
29+
A 0.251661
30+
B 2.516611
31+
C NaN
32+
dtype: float64
33+
"""
34+
35+
import pandas as pd
36+
import numpy as np
37+
from numba import njit
38+
39+
40+
@njit
41+
def dataframe_std():
42+
df = pd.DataFrame({"A": [.2, .0, .6, .2],
43+
"B": [2, 0, 6, 2],
44+
"C": [-1, np.nan, 1, np.inf]})
45+
46+
return df.std()
47+
48+
49+
print(dataframe_std())

sdc/datatypes/hpat_pandas_dataframe_functions.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -818,32 +818,43 @@ def mean_overload(df, axis=None, skipna=None, level=None, numeric_only=None):
818818
@sdc_overload_method(DataFrameType, 'std')
819819
def std_overload(df, axis=None, skipna=None, level=None, ddof=1, numeric_only=None):
820820
"""
821-
Pandas DataFrame method :meth:`pandas.DataFrame.std` implementation.
821+
Intel Scalable Dataframe Compiler User Guide
822+
********************************************
822823
823-
.. only:: developer
824+
Pandas API: pandas.DataFrame.std
824825
825-
Test: python -m sdc.runtests -k sdc.tests.test_dataframe.TestDataFrame.test_std*
826+
Limitations
827+
-----------
828+
Parameters ``axis``, ``level`` and ``numeric_only`` are unsupported.
826829
827-
Parameters
828-
-----------
829-
df: :class:`pandas.DataFrame`
830-
input arg
831-
axis:
832-
*unsupported*
833-
skipna:
834-
*unsupported*
835-
level:
836-
*unsupported*
837-
ddof:
838-
*unsupported*
839-
numeric_only:
840-
*unsupported*
830+
Examples
831+
--------
832+
.. literalinclude:: ../../../examples/dataframe/dataframe_std.py
833+
:language: python
834+
:lines: 35-
835+
:caption: Return sample standard deviation over columns.
836+
:name: ex_dataframe_std
841837
842-
Returns
843-
-------
844-
:obj:`pandas.Series` or `pandas.DataFrame`
845-
return sample standard deviation over requested axis.
846-
"""
838+
.. command-output:: python ./dataframe/dataframe_std.py
839+
:cwd: ../../../examples
840+
841+
.. seealso::
842+
:ref:`Series.std <pandas.Series.std>`
843+
Returns sample standard deviation over Series.
844+
:ref:`Series.var <pandas.Series.var>`
845+
Returns unbiased variance over Series.
846+
:ref:`DataFrame.var <pandas.DataFrame.var>`
847+
Returns unbiased variance over DataFrame.
848+
849+
Intel Scalable Dataframe Compiler Developer Guide
850+
*************************************************
851+
852+
Pandas DataFrame method :meth:`pandas.DataFrame.std` implementation.
853+
854+
.. only:: developer
855+
856+
Test: python -m sdc.runtests -k sdc.tests.test_dataframe.TestDataFrame.test_std*
857+
"""
847858

848859
name = 'std'
849860

0 commit comments

Comments
 (0)