How do I change the data in a single row of an SFrame

User 2568 | 7/5/2016, 10:26:34 PM

As part of my data cleaning I need to change a single row of an SFrame. The item I want to change is product[0] which looks like this.

 'Name': 'NO',
 'NombreProducto': 'NO IDENTIFICADO 0',
 'Peices': None,
 'Producto_ID': 0,
 'Quantity': None,
 'pid': '0'}

I use the commands

product[0]['Code'] = None
product[0]['Name'] = 'NO IDENTIFICADO'

and then look up product[0] again and confirm is has changed. I had not expected this to work as SFrames are immutable, so I checked using filterby, i.e., product.filterby(0, 'Producto_ID') I get

Producto_ID	NombreProducto		Code	Name				Peices	Quantity	pid

which shows it has not changed?

The questions are: 1. What is the idiomatic way to change values in a single row? 2. Why does product[0] indicate that the SFrame has been changed?


User 91 | 7/6/2016, 1:35:48 PM

When you do product[0], you get a dictionary object which can then be changed as is because its a copy of that row, not the actual row in the SFrame. The SFrame is immutable (for many reasons, one of which is wicked performance).

If you have to change the values a single row, then the only way to do it is to use an apply and write an entire column but keep in mind that this operation can be very slow.