Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import numpy as np
import pandas as pd
from scipy.stats import rankdata
def foo(a):
print(a)
return rankdata(a, nan_policy="omit")[-1]
pd.Series([1,3,4, np.nan, 1,2,3]).rolling(3).apply(foo, raw=True)
Issue Description
In this example, I want to get rankdata(a, nan_policy="omit")[-1]
of each window, since Rolling.rank
will return nan if this window contains any nan.
But the example above still return with only two line print :
[1. 3. 4.]
[1. 2. 3.]
0 NaN
1 NaN
2 3.0
3 NaN
4 NaN
5 NaN
6 3.0
dtype: float64
Expected Behavior
Print at least 5 line and the result is:
0 NaN
1 NaN
2 3.0
3 NaN
4 1.0
5 2.0
6 3.0
dtype: float64
Installed Versions
INSTALLED VERSIONS
------------------
commit : 8dab54d6573f7186ff0c3b6364d5e4dd635ff3e7
python : 3.10.6.final.0
python-bits : 64
OS : Linux
OS-release : 3.10.0-1127.el7.x86_64
Version : #1 SMP Thu May 7 02:19:05 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.2
numpy : 1.24.1
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 66.0.0
pip : 22.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.7
lxml.etree : 4.9.2
html5lib : None
pymysql : 1.0.2
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.9.0
pandas_datareader: None
bs4 : 4.11.2
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.3
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.0
snappy : None
sqlalchemy : 2.0.2
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : 2022.7