Adding column of constant value to an SFrame

User 3218 | 2/28/2016, 2:20:30 AM

Hello,

I need to add a column to an existing SFrame, with all values in that column to be a constant. My current way of doing it is as follows:

frequent_rater_ratings.add_column(gl.SArray(np.arange(1, len(frequent_rater_ratings) + 1, 1)), 'user_type') frequent_rater_ratings['user_type'] = frequent_rater_ratings['user_type'].apply(lambda x: 'FREQ')

Is there a better (faster) Graphlab idiom to do this?

Thanks

Comments

User 1592 | 2/28/2016, 4:38:52 AM

Hi Delip, You can try

frequent_rater_ratings['user_type'] = 1


User 3218 | 2/28/2016, 6:13:05 PM

@DannyBickson zen moment :+1: