Background
Let's think, there is a list of values which presents activity of a person for several hours. That person did not have any movement in those hours. Therefore, all the values are 0.
What did raise the question?
Searching on Google, I found the following formula of skewness. The same formula is available in some other sites also. In the denominator part, Standard Deviation (SD) is included. For a list of similar non-zero values (e.g., [1, 1, 1]) and also for 0 values (i.e., [0, 0, 0]), the SD will be 0. Therefore, I am supposed to get NaN
(something divided by 0) for skewness. Surprisingly, I get 0 while calling pandas.DataFrame.skew()
.
My Question
Why does pandas.DataFrame.skew()
return 0 when the SD of a list of values is 0?
Minimum Reproducible Example
import pandas as pd
ot_df = pd.DataFrame(data={'Day 1': [0, 0, 0, 0, 0, 0],
'Day 2': [0, 0, 0, 0, 0, 0],
'Day 3': [0, 0, 0, 0, 0, 0]})
print(ot_df.skew(axis=1))
Note: I have checked several Q&A of this site (e.g., this one (How does pandas calculate skew?)) and others (e.g., this one of GitHub). But I did not find the answer of my question.