예제 #1
0
 def test_find_as_df(self):
     self._save_observations()
     records = [x for x in Observation.find(self.dataset)]
     dframe = Observation.find(self.dataset, as_df=True)
     self.assertTrue(isinstance(dframe, DataFrame))
     self.assertEqual(self.test_data['good_eats.csv'].reindex(
                 columns=dframe.columns), dframe)
     columns = dframe.columns
     for key in MONGO_RESERVED_KEYS:
         self.assertFalse(prefix_reserved_key(key) in columns)
예제 #2
0
파일: mongo.py 프로젝트: asseym/bamboo
def mongo_remove_reserved_keys(_dict):
    for key, value in _dict.items():
        if key in MONGO_RESERVED_KEYS:
            prefixed_key = prefix_reserved_key(key)
            if _dict.get(prefixed_key):
                # replace reserved key value with original key value
                value = _dict.pop(prefixed_key)
                _dict[key] = value
            else:
                # remove mongo reserved keys
                del _dict[key]
        elif value == 'null':
            _dict[key] = np.nan
    return _dict