BUG: read_csv
type hint for na_values
should include non-iterables as valid arguments
#53813
Closed
3 tasks done
Labels
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
Issue Description
The description of valid types in the
read_csv
docstring underna_values
shows:However, the type signature implies that only list-like or dict are valid (not scalar or str):
It appears that the function does actually accept scalar or str (i.e. non-list-list, non-iterable) values as evidenced by the example above, meaning the description is accurate and the type hint needs to be updated to match. The main inconsistencies with the type hint are the following:
[2, 'BBB']
seems to work).Note: this was one of a few items I mentioned in #53763 but I thought it might need its own issue since it affects more than just the docstring. If it should have still been labelled 'DOC', please feel free to update.
Expected Behavior
The behavior seems to be correct, but the type hint should match, perhaps by updating to something like this:
Hashable | Iterable[Hashable] | Mapping[Hashable, Iterable[Hashable]] | None = None
(assumingHashable
is the correct type to cover 'scalar or str` as shown in the description but perhaps someone more familiar could confirm this).Installed Versions
INSTALLED VERSIONS
commit : 965ceca
python : 3.10.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.90.1-microsoft-standard-WSL2
Version : #1 SMP Fri Jan 27 02:56:13 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.0.2
numpy : 1.25.0
pytz : 2023.3
dateutil : 2.8.2
setuptools : 65.6.3
pip : 23.0.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli :
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : 0.19.0
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: