Skip to content

Commit

Permalink
use fill_value
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Aug 11, 2023
1 parent 754b8b2 commit 712fe62
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions rdt/transformers/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def _fit(self, data):
labels = self._order_categories(labels)
freq = data.value_counts(normalize=True, dropna=False)
nan_value = freq[np.nan] if np.nan in freq.index else None
freq = freq.reindex(labels).array
freq[np.isnan(freq)] = nan_value
freq = freq.reindex(labels, fill_value=nan_value).array

self.frequencies, self.intervals = self._compute_frequencies_intervals(labels, freq)

Expand Down Expand Up @@ -269,8 +268,7 @@ def _fit(self, data):
freq = data.value_counts(normalize=True, dropna=False)

nan_value = freq[np.nan] if np.nan in freq.index else None
freq = freq.reindex(self.order).array
freq[np.isnan(freq)] = nan_value
freq = freq.reindex(self.order, fill_value=nan_value).array

self.frequencies, self.intervals = self._compute_frequencies_intervals(self.order, freq)

Expand Down

0 comments on commit 712fe62

Please sign in to comment.