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 pandas as pd
import numpy as np

pd.DataFrame({'A': [np.NaN]}).replace(np.NaN, None)
> RecursionError: maximum recursion depth exceeded while calling a Python object

Issue Description

This was working in an earlier versoin of pandas, but not in 1.5.1 any more.

Expected Behavior

The np.NaNs should be replaced with None in the current dataframe.

Installed Versions

INSTALLED VERSIONS ------------------ commit : 91111fd99898d9dcaa6bf6bedb662db4108da6e6 python : 3.9.15.final.0 python-bits : 64 OS : Linux OS-release : 5.4.0-135-generic Version : #152-Ubuntu SMP Wed Nov 23 20:19:22 UTC 2022 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 1.5.1 numpy : 1.21.5 pytz : 2022.1 dateutil : 2.8.2 setuptools : 65.5.0 pip : 22.2.2 Cython : None pytest : 6.2.5 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : 3.0.2 lxml.etree : 4.6.4 html5lib : None pymysql : None psycopg2 : 2.9.5 jinja2 : 3.0.3 IPython : 8.6.0 pandas_datareader: None bs4 : 4.10.0 bottleneck : 1.3.5 brotli : fastparquet : 0.7.1 fsspec : 2021.11.0 gcsfs : None matplotlib : 3.6.1 numba : 0.55.1 numexpr : 2.8.3 odfpy : None openpyxl : 3.0.9 pandas_gbq : None pyarrow : 6.0.0 pyreadstat : None pyxlsb : None s3fs : None scipy : 1.6.2 snappy : None sqlalchemy : 1.4.27 tables : 3.6.1 tabulate : 0.8.9 xarray : None xlrd : 2.0.1 xlwt : None zstandard : None tzdata : None

Comment From: mroeschke

I believe this is fixed if you install 1.5.2 https://pandas.pydata.org/docs/dev/whatsnew/v1.5.2.html

Comment From: sorenwacker

Confirmed. For some reason my conda update pandas did not update pandas accordingly. Thanks