signaux-faibles / predictsignauxfaibles

Dépôt du code python permettant la production de liste de prédiction Signaux Faibles.
MIT License
6 stars 1 forks source link

Fields in SFDataset can be silently missing after fetch #43

Closed vviers closed 3 years ago

vviers commented 3 years ago

Problem

When requesting a specific field from the database on a small number of observations, if the field is not in any document returned by MongoDB then no column will be created for it in the dataset.

This is potentially surprising for a developper as you can be requesting 30 fields and only get 25 in the resulting dataset.

Solution

Since this is the expected/normal behavior from a document-oriented DB like Mongo, the solution should be implemented on our side.

I suggest having the self.fetch_data method compare self.fields with self.data.columns and create columns of NAs