Quantcast
Viewing all articles
Browse latest Browse all 14069

python apply(zscore) problem ( i don't know why the value is NaN in the column)

heollo

i'm studying python through books.

in the book, there are the coding below.but, on my computer, it doesn't work.

data_bind['z-score'] = data_bind.groupby('SEC_NM', dropna=False)['return'].apply(zscore,   nan_policy='omit')

[result]print(data_bind)code SEC_NM return rank z-score0 111 000020 0.023614 248.0 NaN1 112 000040 -0.256716 627.0 NaN.....

print(data_bind.groupby('SEC_NM', dropna=False)['return'].apply(zscore, nan_policy='omit'))SEC_NM000020 [0.1436575842145283, -0.5022560341142324, 0.05...000040 [0.4589118861712773, 1.4471044349054212, -0.43.......

how i can resolve that?give me some advice, please.

data_bind = data_bind.dropna()data_bind = data_bind.groupby('SEC_NM_KOR', dropna=False)data_bind['z-score'] = zscore(data_bind['return'])

this coding also doesn't work...


Viewing all articles
Browse latest Browse all 14069

Trending Articles