Skip to content

BUG from_csv na_filter=False not working with index #18143

Closed
@jebob

Description

@jebob

Code Sample, a copy-pastable example if possible

pd.DataFrame({"col1": ["NA"], "col2": ["NA"]}).to_csv("test.csv", index=False, header=None)

output = pd.read_csv("test.csv", header=None, names=["iso2", "region"], index_col="iso2", na_filter=False)
print(output)

Problem description

Reading the file, "test.csv", with na_filter set to false, causes a "NA" to be read as a nan when that column is converted into the index. Reading the file without index_col and then converting works.

Expected Output

The index should contain the string "NA", not the float nan.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.20.3
pytest: 3.2.3
pip: 9.0.1
setuptools: 36.5.0
Cython: None
numpy: 1.13.1
scipy: 1.0.0b1
xarray: None
IPython: None
sphinx: None
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions