Roo
Roo

Reputation: 912

Scipy gmean with missing values

I was not sure how to deal with a two dimensional array [stock returns] that has some missing values.

I want to get geometric mean for each row [ average return for each month]. I got missing values for geometric mean for those months that I have missing values.

One way is to filling the missing values with something like 1 or mean but I don't want to mess with the mean.

Any advice how to calculate the gmean for each date just based on the not-missing values?

enter image description here

enter image description here

Upvotes: 1

Views: 1005

Answers (1)

0TTT0
0TTT0

Reputation: 1332

You should go with numpy.nanmean()

https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.nanmean.html

Upvotes: 1

Related Questions