我对如何在SFrame数组中选择特定行感到困惑。我可以在这里选择第一行:
sf
+-------------------------------+
| X1 |
+-------------------------------+
| [0.0, 0.0, 0.0, 0.0, 0.0, ... |
[100 rows x 1 columns]
sf[:1]
+-------------------------------+
| X1 |
+-------------------------------+
| [0.0, 0.0, 0.0, 0.0, 0.0, ... |
[1 rows x 1 columns]
sf[:2]
+-------------------------------+
| X1 |
+-------------------------------+
| [0.0, 0.0, 0.0, 0.0, 0.0, ... |
| [0.0, 0.0, 0.0, 0.0, 0.0, ... |
[2 rows x 1 columns]
type(sf[:1])
graphlab.data_structures.sframe.SFrame我试着弄到第二排
sf[:,2]
# TypeError: Invalid key type: must be str, bytes or type如何在dataframe中选择任何行?
发布于 2016-06-27 10:45:57
您可以使用以下内容选择一行:
import graphlab as gl
sf = gl.SFrame({'a':[1,2,3], 'b':[2,9,1]})
# select first row
print sf[0]
# select second row
print sf[1]
# and so on
# convert first row to an SFrame
sf_one_raw = sf[0:1]
# convert second row to an SFrame
sf_one_raw = sf[1:2]https://stackoverflow.com/questions/38044536
复制相似问题