熊猫:更改过滤的数据帧列

时间:2016-11-14 01:57:25

标签: python pandas

我试图将过滤后的数据帧传入一个旨在操纵某些列的函数(再次使用过滤)。我知道这已经出现过很多次了,但即使在阅读了文档和其他相关问题之后,我仍然无法解决问题。我想我只需要一个可以开始试验的工作实例。

这是我失败的尝试。 ; pseudo code follows, replace it by actual x86 instructions ; and registers as you wish ; ("r16_something" means one of 16b register, r8 is 8b register) lea r16_str1,[str1] ; load CPU with address of str1 mov r16_counter,str1size ; load CPU with str1 size value lea r16_str2,[str2] ; load address of target buffer loop_per_character: mov r8_char,[r16_str1] ; read single character cmp r8_char,'0' jne skip_non_ascii_zero_char ; the character is equal to ASCII '0' character (value 48) mov r8_char,'O' ; replace it with 'O' skip_non_ascii_zero_char: ; here the character was modified as needed, write it to str2 buffer mov [r16_str2],r8_char ; make both str1/2 pointers to point to next character inc r16_str1 inc r16_str2 ; count down the counter, and loop until zero is reached dec r16_counter jnz loop_per_character ; the memory starting at "str2" should now contain ; modified copy of "str1" ; ... add exit instructions ... 将是从我的实际用例传递给列操作函数的值。

s1

1 个答案:

答案 0 :(得分:0)

我认为你应该使用函数.ix

例如:

df1.ix[df1['a']<=2, 'b'] = 0

你想实现吗?