简体   繁体   中英

SFrame: replacing of specific rows in the column

Sorry, I have probably some simple question. I have SFrame looks like this:

A B C
0 1 2
0 2 3
1 2 3
1 3 4
2 3 1
2 3 3
. . .

Also I have another SFrame, looks like this:

A B C
0 1 4
0 2 5

I want replace SFrame with the similar A & B values, but with new C values.

A B C
0 1 4
0 2 5
1 2 3
1 3 4
2 3 1
2 3 3
. . .

It could be the all columns in the firstSFrame, but also just one column (SArray).

I try it with the next prompt:

sfr['C'][sfr['A']==0] = sfr2['C']

or just

sfr[sfr['A']==0] = sfr2

but got next error message:

TypeError: 'SArray' object does not support item assignment

Anyway, When I replace the SArray C from the similar length, this solution is worked.... The problem is in the different lengths of SFrames...

At the moment, I found someself a simple solution. I create a list from all values, which I want replace in the first SFrame. Then convert this list to SArray and add it as a new column. (the number of columns is not important for me)...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM