How to add a column of ones to SFrame with unknown number of rows?

User 2908 | 12/27/2015, 1:13:08 PM

I have a SFrame (number of rows unknown) and want to add a column with ones. How can I do that?


User 2156 | 12/28/2015, 2:33:19 AM

Hi Jurjen,

There is always a way to determine the number of rows before your add a column.

Here are the docs might be helpful for your problem.

User 1178 | 12/28/2015, 7:28:42 PM

Hi Jurjen,

There is an easy way to add a column of constants to an SFrame:


this is your SFrame

sf = ...

add a new column where values are all 1s

sf['newcolumnname'] = 1 `

Hope this helps!


User 2908 | 12/29/2015, 5:14:20 PM

Hi Ping. Yes, that helped. Thanks! And Kaiyu, thanks for the info.