search
Search
Unlock 100+ guides
search toc
close
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview Doc Search Code Search Beta SORRY NOTHING FOUND!
mic
Start speaking... Voice search is only supported in Safari and Chrome.
Shrink
Navigate to
check_circle
Mark as learned
thumb_up
0
thumb_down
0
chat_bubble_outline
0
Comment
auto_stories Bi-column layout
settings

# Pandas DataFrame | sem method

schedule Aug 10, 2023
Last updated
local_offer
PythonPandas
Tags
expand_more
mode_heat
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!

Pandas DataFrame.sem(~) method returns the unbiased standard error of the mean for each row or column of the source DataFrame.

Note that the unbiased standard error of the mean is defined as follows:

$$\sigma_\bar{X}=\frac{\sigma_X}{\sqrt{n}}$$

Where,

• $\sigma_\bar{X}$ is the unbiased standard error of the mean

• $\sigma_X$ is the unbiased sample standard deviation (normalized by $n-1$ by default).

• $n$ is the sample size (number of values in a column or row).

# Parameters

1. axislink | int or string | optional

Whether to compute the statistic row-wise or column-wise:

Axis

Description

0 or "index"

Compute the SEM for each column.

0 or "columns"

Compute the SEM for each row.

By default, axis=0.

2. skipna | boolean | optional

Whether or not to ignore NaN. By default, skipna=True.

3. level | int or string | optional

The level to target if the source DataFrame is a multi-index.

4. ddof | int | optional

The delta degree of freedom. This can be used to modify the denominator ddof of the sample variance:

$$\sigma_{X}^2=\frac{1}{N{\color{#6495ed}-ddof}}\sum_{i=0}^{N}\left(x_i-\bar{x}^2\right)$$

By default, ddof=1. Note that $\sigma_X$ is used to compute the SEM.

# Return Value

If the level parameter is specified, then a DataFrame will be returned. Otherwise, a Series will be returned.

# Examples

Consider the following DataFrame:

 df = pd.DataFrame({"A":[2,5,8], "B":[4,5,6]}, index=["a","b","c"])df    A  Ba  2  4b  5  5c  8  6 

## Computing SEM of each column

By default, axis=0, which means that we compute the SEM of each column:

 df.sem() A 1.732051B 0.577350dtype: float64 

## Computing SEM of each row

To compute the SEM of each row instead, pass in axis=1 like so:

 df.sem(axis=1) a 1.0b 0.0c 1.0dtype: float64 
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!