python - Pandas: Replacing column values in dataframe -


I am trying to change values ​​in a column of dataframe column ('female') only in 'female' and I have tried the following:

  w ['female'] ['female'] = '1' [woman]] [ 'Male'] = '' 0 ''   

but get exact copies of the previous results.

I would ideally like to get some output which looks like the lower loop element. / P>

  if w ['female'] == 'female': w ['female'] = '1'; Else: w ['female'] = '0';   

I have seen through the gotchas documentation () but it is not able to understand why nothing happens.

Any help would be appreciated.

If I think right, then you want something like this:

 < Code> w ['female'] = w ['female']. Map ({'feminine': 1, 'male': 0})   

(Here I change numbers in numbers instead of stars. You can convert "1 " and " 0 ", if you really want, but I'm not sure why you want to do this.)

Your code is not working The reason for this is that someone is using ['female'] on any column (second 'female' in your w ['female']] 'Female'] does not mean "selection of rows Where the value is 'female'. This means that select the rows where index is 'female', none of which can be in your dataframe.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -