Skip to content

Commit

Permalink
BUG: icol() should propegate fill_value for sparse data frames #2249
Browse files Browse the repository at this point in the history
  • Loading branch information
y-p authored and wesm committed Nov 15, 2012
1 parent 2335d10 commit 2267a65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1740,8 +1740,15 @@ def icol(self, i):
return self.ix[:, i]

values = self._data.iget(i)
return self._col_klass.from_array(values, index=self.index,
name=label)
if hasattr(self,'default_fill_value'):
s = self._col_klass.from_array(values, index=self.index,
name=label,
fill_value= self.default_fill_value)
else:
s = self._col_klass.from_array(values, index=self.index,
name=label)

return s

def _ixs(self, i, axis=0):
if axis == 0:
Expand Down
4 changes: 2 additions & 2 deletions pandas/sparse/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ def __new__(cls, data, index=None, sparse_index=None, kind='block',
return output

@classmethod
def from_array(cls, arr, index=None, name=None, copy=False):
def from_array(cls, arr, index=None, name=None, copy=False,fill_value=None):
"""
Simplified alternate constructor
"""
return SparseSeries(arr, index=index, name=name, copy=copy)
return SparseSeries(arr, index=index, name=name, copy=copy,fill_value=fill_value)

def __init__(self, data, index=None, sparse_index=None, kind='block',
fill_value=None, name=None, copy=False):
Expand Down

0 comments on commit 2267a65

Please sign in to comment.