From e47ffb3fae96adc99f52b601a891e3d65fd4ae31 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Wed, 10 Aug 2022 17:06:33 -0500 Subject: [PATCH] bug fix: random empty values --- data/maker/prepare/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/maker/prepare/__init__.py b/data/maker/prepare/__init__.py index f025294..1fae46c 100644 --- a/data/maker/prepare/__init__.py +++ b/data/maker/prepare/__init__.py @@ -265,7 +265,11 @@ class Input : _values = np.array( list(self._map.values())) _matrix = pd.DataFrame(_matrix) #if type(_matrix) != pd.DataFrame else _matrix # x = _matrix.apply(lambda row: _values[row.values == 1 ].tolist()[0] if row.values.sum() > 0 else None, axis=1).tolist() - x = _matrix.apply(lambda row: _values[row.values == 1].tolist()[0] if (row.values == 1).sum() > 0 else np.repeat(None,len(self._columns)) ,axis=1).tolist() + #@TODO: Provide random values for things that are missing + + # x = _matrix.apply(lambda row: _values[row.values == 1].tolist()[0] if (row.values == 1).sum() > 0 else np.repeat(None,len(self._columns)) ,axis=1).tolist() + + x = _matrix.apply(lambda row: _values[row.values == 1].tolist()[0] if (row.values == 1).sum() > 0 else np.random.choice(np.matrix.flatten(_values,1)).tolist() ,axis=1).tolist() return pd.DataFrame(x,columns=columns)