@@ -546,6 +546,53 @@ The ``thousands`` keyword allows integers to be parsed correctly
546
546
547
547
os.remove(' tmp.csv' )
548
548
549
+ .. _io.na_values :
550
+
551
+ NA Values
552
+ ~~~~~~~~~
553
+
554
+ To control which values are parsed as missing values (which are signified by ``NaN ``), specifiy a
555
+ list of strings in ``na_values ``. If you specify a number (a ``float ``, like ``5.0 `` or an ``integer `` like ``5 ``),
556
+ the corresponding equivalent values will also imply a missing value (in this case effectively
557
+ ``[5.0,5] `` are recognized as ``NaN ``.
558
+
559
+ To completely override the default values that are recognized as missing, specify ``keep_default_na=False ``.
560
+ The default ``NaN `` recognized values are ``['-1.#IND', '1.#QNAN', '1.#IND', '-1.#QNAN', '#N/A N/A', 'NA',
561
+ '#NA', 'NULL', 'NaN', 'nan'] ``.
562
+
563
+ .. code-block :: python
564
+
565
+ read_csv(path, na_values = [5 ])
566
+
567
+ the default values, in addition to ``5 `` , ``5.0 `` when interpreted as numbers are recognized as ``NaN ``
568
+
569
+ .. code-block :: python
570
+
571
+ read_csv(path, keep_default_na = False , na_values = [" " ])
572
+
573
+ only an empty field will be ``NaN ``
574
+
575
+ .. code-block :: python
576
+
577
+ read_csv(path, keep_default_na = False , na_values = [" NA" , " 0" ])
578
+
579
+ only ``NA `` and ``0 `` as strings are ``NaN ``
580
+
581
+ .. code-block :: python
582
+
583
+ read_csv(path, na_values = [" Nope" ])
584
+
585
+ the default values, in addition to the string ``"Nope" `` are recognized as ``NaN ``
586
+
587
+ .. _io.infinity :
588
+
589
+ Infinity
590
+ ~~~~~~~~
591
+
592
+ ``inf `` like values will be parsed as ``np.inf `` (positive infinity), and ``-inf `` as ``-np.inf `` (negative infinity).
593
+ These will ignore the case of the value, meaning ``Inf ``, will also be parsed as ``np.inf ``.
594
+
595
+
549
596
.. _io.comments :
550
597
551
598
Comments
0 commit comments