The Pandas core window rolling Rolling function sem() used to calculate the rolling standard error of mean. It returns either Series or DataFrame as the original object with np.float64 dtype.
1 Rolling.sem(ddof = 1, numeric_only = False)
ddof : It is an integer that specifies the Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. If not specified the default value will be 1.
numeric_only : It can be boolean value that include only float, int, or boolean data. If not specified the default value will be False.
1 import pandas as pd
2
3 ser = pd.Series([1, 2, 3, 2, 5])
4 rolling = ser.rolling(2, min_periods = 1)
5 res = rolling.sem()
6 print('The unbiased standard error of the mean :')
7 print(res)
In the above example, an Series object is created by passing an array. A rolling sem() function is called that compute the unbiased standard error of mean and assign result to the variable that will be printed on console.
1 The unbiased standard error of the mean :
2 0 NaN
3 1 0.707107
4 2 0.707107
5 3 0.707107
6 4 2.121320
7 dtype: float64
Example 2
1 import pandas as pd
2
3 ser = pd.Series([1, 2, 3, 4])
4 print('The series object :')
5 print(ser)
6
7 rolling = ser.rolling(2, min_periods = 1)
8 res = rolling.sem()
9 print('The unbiased standard error of the mean :')
10 print(res)
In the above example, an Series object is created by passing an array. A rolling sem() function is called that compute the unbiased standard error of mean and assign result to the variable.
1 The series object :
2 0 1
3 1 2
4 2 3
5 3 4
6 dtype: int64
7 The unbiased standard error of the mean :
8 0 NaN
9 1 0.707107
10 2 0.707107
11 3 0.707107
12 dtype: float64
Related options for your search