查找行"不适用"来自Graphlab SFrame的特定列的值

时间:2015-12-17 01:16:23

标签: python dataframe na graphlab sframe

给定具有以下列名的Graphlab.SFrame对象:

>>> import graphlab
>>> sf = graphlab.SFrame.read_csv('some.csv')
>>> s.column_names()
['Dataset', 'Domain', 'Score', 'Sent1', 'Sent2']

可以轻易地删除行"不适用" (NA)/特定列中的无值,例如删除带有NA值的行"得分"专栏,我可以这样做:

>>> sf.dropna('Score')

或者将None值替换为某个值(让我们说-1),我可以这样做:

>>> sf.fillna('Score', -1)

在检查来自https://dato.com/products/create/docs/generated/graphlab.SFrame.html的SFrame文档后,没有内置函数来查找某个列包含无的行,例如sf.findna('Score')。或者我可能错过了它。

如果有这样的功能,它叫什么?

如果没有我应该如何提取具有NA值的该行中指定列的行?

1 个答案:

答案 0 :(得分:2)

我认为您可以使用布尔数组来标识给定列的缺少值的行。

<form name="input" method="get">
<h3>How do you want the information displayed in the Purchase Order Total Box at the
bottom of the page?</h3> 
<input type="checkbox" name="POTBDetail" id = "POTBDetail" value="Detail">Detail (Please check off all items you want displayed in the box) See Ply 1 – G of template for printed example<br>
<input type="checkbox" style = "margin-left:5em" name="POLIT" id = "POLIT" value="PO Line Item Total">PO Line Item Total<br>
<input type="checkbox" style = "margin-left:5em" name="CT" id = "CT" value="Credit Total">Credit Total<br>
<input type="checkbox" style = "margin-left:5em" name="STT" id = "STT" value="STT">Sales Tax Total<br>
<input type="checkbox" style = "margin-left:5em" name="DT" id = "DT" value="Discount Total">Discount Total<br>
<input type="checkbox" style = "margin-left:5em" name="FT" id = "FT" value="Freight Total">Freight Total<br>
<input type="checkbox" name="POTBTotal" id = "POTBTotal" value="Total">Show PO Total Only, no Detail Items See Ply 3 – C of template for printed example<br>
<input type="checkbox" name="POTBNone" id = "POTBNone" value="None">None – I don’t require a PO Total Box on this copy of the PO<br>
<h3></h3> 

<input type="button" value = "convert to text!" id = "button" onClick = "add()"/>
</br>
<textarea id = "output" style = "width:90%;height:40%;" onClick = "this.select();"></textarea>
</form>