Search code examples
pythonpandasmachine-learningdata-analysisgraphlab

graphlab create sframe how to get SArray median


I'm studying graphlab create with

data=graphlab.SFrame.read_csv('test.csv')

im trying to get median of one of columns

data_train.fillna(('Credit_History',data_train['Credit_History'].median()))

but I got error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-247-50ed3eb09dcc> in <module>()
----> 1 data_train.fillna(('Credit_History',data_train['Credit_History'].median()))

AttributeError: 'SArray' object has no attribute 'median'

data.show() will show median of this column though anyone knows how to fix this?


Solution

  • I think I understand what your trying to do. Sframe doesn't have a default median function. I would improvise like this:

    import numpy as np
    data_train.fillna('Credit_History', np.median(data_train['Credit_History']))