Skip to content

API/ENH: easier configurable NA values for parsing #19156

Closed
@chris-b1

Description

@chris-b1

xref #16079 (adding lowercase n/a to default missing values) - I have a case where I want to treat 'n/a' as non-missing, but keep the rest of the default behavior. It seems this is about the best I can do, which involves an internal value.

from io import StringIO
data = '''a,b
1,2
3,n/a'''
pd.read_csv(StringIO(data), 
    na_values=pd.io.common._NA_VALUES.difference(['n/a']), 
    keep_default_na=False)

Not suggesting reverting #16079, but wonder if if there might be a better way to expose through some kind of option? Initial idea was something like pd.options.na_values (set to the current _NA_VALUES), though might be issues using a mutable value as an option. Also could expose something like pd.io.DEFAULT_NA_VALUES

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