Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
This example function gives an error if passed as an argument to apply
aux = pd.Series([1,1,1,1,2,2,3,4,], dtype='uint32')
@numba.jit(numba.float64(numba.uint32[:]), nopython=True)
def nunique(arr):
return len(set(arr))
aux.rolling(2).apply(nunique, raw=True)
This raises the following error:
TypeError: No matching definition for argument type(s) array(float64, 1d, C)
Issue Description
If you try to use a function that receives anything other than a float on a rolling window, it will give you an error. This is because everything is converted to float beforehand.
Furthermore, arithmetic addition is not invertible for floating point1
Expected Behavior
raw=True
should respect types
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.10.10.final.0
python-bits : 64
OS : Linux
OS-release : 6.1.26-1-MANJARO
Version : #1 SMP PREEMPT_DYNAMIC Wed Apr 26 22:07:35 UTC 2023
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.5.3
numpy : 1.23.5
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 22.3.1
Cython : None
pytest : 7.2.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.8.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : 1.0.9
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.3
numba : 0.56.4
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.0
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.8.10
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : 2023.3
Footnotes
-
Martin Hirzel, Scott Schneider, and Kanat Tangwongsan. 2017. Sliding-Window Aggregation Algorithms: Tutorial. In Proceedings of the 11th ACM International Conference on Distributed and Event-based Systems (DEBS '17). Association for Computing Machinery, New York, NY, USA, 11–14. https://doi.org/10.1145/3093742.3095107 ↩