可以使用Array#drop删除数组的前n个元素。
a = [1,2,3]
a.drop(2) # => [3]我想从Daru::DataFrame对象中删除前n行。这个类似乎没有实现这样的drop方法。
如何从Daru::DataFrame对象中删除前n行?
发布于 2018-11-27 10:26:12
您可以使用在…检索所有行,而不需要前4行。
示例:
2.4.5 :001 > require 'daru'
=> true
2.4.5 :002 > df = Daru::DataFrame.new({
2.4.5 :003 > 'col0' => [1,2,3,4,5,6],
2.4.5 :004 > 'col2' => ['a','b','c','d','e','f'],
2.4.5 :005 > 'col1' => [11,22,33,44,55,66]
2.4.5 :006?> })
=> #<Daru::DataFrame(6x3)>
col0 col2 col1
0 1 a 11
1 2 b 22
2 3 c 33
3 4 d 44
4 5 e 55
5 6 f 66检索行:
2.4.5 :010 > df.row_at(4..df.shape()[0])
=> #<Daru::DataFrame(2x3)>
col0 col2 col1
4 5 e 55
5 6 f 66发布于 2019-01-08 10:03:32
https://stackoverflow.com/questions/53497206
复制相似问题