Whats the right way to use a SparseDataFrame in Pandas? -


pandas.dataframe(a) out[41]:     1   2   3 0  1   2 nan 1  1 nan   3  = [{1:1.0,2:2.0}, {1:1.0,3:3.0}]  pandas.dataframe(a) out[43]:     1   2   3 0  1   2 nan 1  1 nan   3  pandas.sparsedataframe(a) --------------------------------------------------------------------------- typeerror                                 traceback (most recent call last) <ipython-input-44-50288c1b1994> in <module>() ----> 1 pandas.sparsedataframe(a)  /library/python/2.7/site-packages/pandas/sparse/frame.pyc in __init__(self, data, index, columns, default_kind, default_fill_value)      94             sdict, columns, index = self._init_dict(data, index, columns)      95         elif isinstance(data, (np.ndarray, list)): ---> 96             sdict, columns, index = self._init_matrix(data, index, columns)      97         elif isinstance(data, dataframe):      98             sdict, columns, index = self._init_dict(data, data.index,  /library/python/2.7/site-packages/pandas/sparse/frame.pyc in _init_matrix(self, data, index, columns, dtype)     203      204         data = dict([(idx, data[:, i]) i, idx in enumerate(columns)]) --> 205         return self._init_dict(data, index, columns, dtype)     206      207     def __array_wrap__(self, result):  /library/python/2.7/site-packages/pandas/sparse/frame.pyc in _init_dict(self, data, index, columns, dtype)     174                     v = [v.get(i, nan) in index]     175  --> 176                 v = sp_maker(v)     177             sdict[k] = v     178   /library/python/2.7/site-packages/pandas/sparse/frame.pyc in <lambda>(x)     159                                           kind=self.default_kind,     160                                           fill_value=self.default_fill_value, --> 161                                           copy=true)     162      163         sdict = {}  /library/python/2.7/site-packages/pandas/sparse/series.pyc in __new__(cls, data, index, sparse_index, kind, fill_value, name, copy)     127             if sparse_index none:     128                 values, sparse_index = make_sparse(data, kind=kind, --> 129                                                    fill_value=fill_value)     130             else:     131                 values = data  /library/python/2.7/site-packages/pandas/sparse/array.pyc in make_sparse(arr, kind, fill_value)     426      427     if np.isnan(fill_value): --> 428         mask = -np.isnan(arr)     429     else:     430         mask = arr != fill_value  typeerror: ufunc 'isnan' not supported input types, , inputs not safely coerced supported types according casting rule 'safe' 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -