heollo
i'm studying python through books.
in the book, there are the coding below.
i want to make a column named 'z-score' but, it doesn't work. (['z-score'] values are NaN)
data_bind = data_bind.dropna()
print(data_bind)
code name CMP_CD SEC_NM return rank
0 000020 donghwa 000020 health 0.023614 248.0
1 000040 motors 000040 economy -0.256716 627.0
2 000050 bang 000050 economy -0.288800 659.0
3 000070 samyang 000070 material 0.020528 256.0
4 000080 hite 000080 necessary -0.358872 713.0
......
data_bind['z-score'] = data_bind.groupby('SEC_NM', dropna=False)['return'].apply(zscore, nan_policy='omit')
print(data_bind)
code SEC_NM return rank z-score
0 000020 health 0.023614 248.0 NaN
1 000040 economy -0.256716 627.0 NaN
.....
print(data_bind.groupby('SEC_NM', dropna=False)['return'].apply(zscore, nan_policy='omit'))
SEC_NM
health [0.1436575842145283, -0.5022560341142324, 0.05...
economy [0.4589118861712773, 1.4471044349054212, -0.43...
...
how i can resolve that? give me some advice, please.