Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/tech/v3/dataset/io/column_parsers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@
^IMutList failed-values
^RoaringBitmap failed-indexes
column-name
^:unsynchronized-mutable ^long max-idx]
^:unsynchronized-mutable ^long max-idx
disable-na-as-missing?]
dtype-proto/PECount
(ecount [_this] (inc max-idx))
Indexed
Expand All @@ -216,7 +217,7 @@
;;be in the space of the container or it could require the parse-fn
;;to make it.
(let [parsed-value (cond
(missing-value? value false)
(missing-value? value disable-na-as-missing?)
:tech.v3.dataset/missing
(and (identical? (dtype/datatype value) container-dtype)
(not (instance? String value)))
Expand Down Expand Up @@ -299,20 +300,18 @@
missing (bitmap/->bitmap)]
(FixedTypeParser. container dtype missing-value parse-fn
missing failed-values failed-indexes
cname -1)))

cname -1
(get options :disable-na-as-missing?))))

(defn parser-kwd-list->parser-tuples
[kwd-list]
(mapv parser-entry->parser-tuple kwd-list))


(def default-parser-datatype-sequence
[:bool :int16 :int32 :int64 :float64 :uuid
:packed-duration :packed-local-date
:zoned-date-time :string :text :boolean])


(defn- promote-container
^IMutList [old-container ^RoaringBitmap missing new-dtype options]
(let [n-elems (dtype/ecount old-container)
Expand Down
6 changes: 6 additions & 0 deletions test/tech/v3/dataset_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,12 @@
(is (= expected-column (:a ds1)))
(is (= expected-column (:a ds2)))))

(deftest fixed-type-disable-na-as-missing
(let [data [{:a "no"} {:a "NA"} {:a "na"}]
ds1 (ds/->dataset data {:parser-fn :string :disable-na-as-missing? true})
ds2 (ds/->dataset data {:parser-fn :string :disable-na-as-missing? false})]
(is (= ["no" "NA" "na"] (:a ds1)))
(is (= ["no" nil nil] (:a ds2)))))

(deftest sub-buffer-col-incorrect-missing
(let [ds (-> (ds/->dataset {:a (range 20)})
Expand Down