Search code examples
pythonmlrun

How to handle writing None values to Integer type in NoSqlTarget with MLRun?


Issue with write None value to Integer type in NoSqlTarget?

I used this code (everything seems fine), but feature 'ka1' does not contain None value:

import mlrun
import mlrun.feature_store as fstore
... 
project = mlrun.get_or_create_project("test", context='./', user_project=False)

fset = fstore.FeatureSet(feature_name, entities=[fstore.Entity("ka0")],engine="storey") 
fset.set_targets(targets=[mlrun.datastore.NoSqlTarget()],with_defaults=False)
fset.save()
... 
data = pandas.DataFrame(numpy.random.randint(low=0, high=500,size=(1, 5)), 
   columns=[f"ka{i}" for i in range(10)]) 

data[0, 'ka1']=None  # tested None (empty) value
...
fstore.ingest(fset,data)

Do you know, how can I write the None value to integrer type in NoSqlTarget correnty?


Solution

  • You have to change the write value to the pandas dataframe, see updated small part of your code (the rest seems fine):

    ...
    # valid is math.nan
    dataFrm.at[0, 'fn3']=math.nan
    
    # valid is numpy.nan
    dataFrm.at[0, 'fn3']=numpy.nan
    ...