Skip to content

Commit edd0522

Browse files
authored
docs: add examples for dataframe.mean, dataframe.median, dataframe.va… (#228)
* docs: add examples for dataframe.mean, dataframe.median, dataframe.var and dataframe.skew * column to columns * update var example
1 parent f9c6e72 commit edd0522

File tree

1 file changed

+103
-2
lines changed
  • third_party/bigframes_vendored/pandas/core

1 file changed

+103
-2
lines changed

third_party/bigframes_vendored/pandas/core/frame.py

+103-2
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,33 @@ def sum(self, axis=0, *, numeric_only: bool = False):
28522852
def mean(self, axis=0, *, numeric_only: bool = False):
28532853
"""Return the mean of the values over the requested axis.
28542854
2855+
**Examples:**
2856+
2857+
>>> import bigframes.pandas as bpd
2858+
>>> bpd.options.display.progress_bar = None
2859+
2860+
>>> df = bpd.DataFrame({"A": [1, 3], "B": [2, 4]})
2861+
>>> df
2862+
A B
2863+
0 1 2
2864+
1 3 4
2865+
<BLANKLINE>
2866+
[2 rows x 2 columns]
2867+
2868+
Calculating the mean of each column (the default behavior without an explicit axis parameter).
2869+
2870+
>>> df.mean()
2871+
A 2.0
2872+
B 3.0
2873+
dtype: Float64
2874+
2875+
Calculating the mean of each row.
2876+
2877+
>>> df.mean(axis=1)
2878+
0 1.5
2879+
1 3.5
2880+
dtype: Float64
2881+
28552882
Args:
28562883
axis ({index (0), columns (1)}):
28572884
Axis for the function to be applied on.
@@ -2865,7 +2892,27 @@ def mean(self, axis=0, *, numeric_only: bool = False):
28652892
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
28662893

28672894
def median(self, *, numeric_only: bool = False, exact: bool = False):
2868-
"""Return the median of the values over the requested axis.
2895+
"""Return the median of the values over colunms.
2896+
2897+
**Examples:**
2898+
2899+
>>> import bigframes.pandas as bpd
2900+
>>> bpd.options.display.progress_bar = None
2901+
2902+
>>> df = bpd.DataFrame({"A": [1, 3], "B": [2, 4]})
2903+
>>> df
2904+
A B
2905+
0 1 2
2906+
1 3 4
2907+
<BLANKLINE>
2908+
[2 rows x 2 columns]
2909+
2910+
Finding the median value of each column.
2911+
2912+
>>> df.median()
2913+
A 1.0
2914+
B 2.0
2915+
dtype: Float64
28692916
28702917
Args:
28712918
numeric_only (bool. default False):
@@ -2884,6 +2931,34 @@ def var(self, axis=0, *, numeric_only: bool = False):
28842931
28852932
Normalized by N-1 by default.
28862933
2934+
**Examples:**
2935+
2936+
>>> import bigframes.pandas as bpd
2937+
>>> bpd.options.display.progress_bar = None
2938+
2939+
>>> df = bpd.DataFrame({"A": [1, 3], "B": [2, 4]})
2940+
>>> df
2941+
A B
2942+
0 1 2
2943+
1 3 4
2944+
<BLANKLINE>
2945+
[2 rows x 2 columns]
2946+
2947+
Calculating the variance of each column (the default behavior without an explicit axis parameter).
2948+
2949+
>>> df.var()
2950+
A 2.0
2951+
B 2.0
2952+
dtype: Float64
2953+
2954+
Calculating the variance of each row.
2955+
2956+
>>> df.var(axis=1)
2957+
0 0.5
2958+
1 0.5
2959+
dtype: Float64
2960+
2961+
28872962
Args:
28882963
axis ({index (0), columns (1)}):
28892964
Axis for the function to be applied on.
@@ -2897,10 +2972,36 @@ def var(self, axis=0, *, numeric_only: bool = False):
28972972
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
28982973

28992974
def skew(self, *, numeric_only: bool = False):
2900-
"""Return unbiased skew over requested axis.
2975+
"""Return unbiased skew over columns.
29012976
29022977
Normalized by N-1.
29032978
2979+
**Examples:**
2980+
2981+
>>> import bigframes.pandas as bpd
2982+
>>> bpd.options.display.progress_bar = None
2983+
2984+
>>> df = bpd.DataFrame({'A': [1, 2, 3, 4, 5],
2985+
... 'B': [5, 4, 3, 2, 1],
2986+
... 'C': [2, 2, 3, 2, 2]})
2987+
>>> df
2988+
A B C
2989+
0 1 5 2
2990+
1 2 4 2
2991+
2 3 3 3
2992+
3 4 2 2
2993+
4 5 1 2
2994+
<BLANKLINE>
2995+
[5 rows x 3 columns]
2996+
2997+
Calculating the skewness of each column.
2998+
2999+
>>> df.skew()
3000+
A 0.0
3001+
B 0.0
3002+
C 2.236068
3003+
dtype: Float64
3004+
29043005
Args:
29053006
numeric_only (bool, default False):
29063007
Include only float, int, boolean columns.

0 commit comments

Comments
 (0)