Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23247

matching numpy conditions row and column without iteration

$
0
0

Given a dataframe condition defined as:

0    [3, 4]1       [2]

I want another dataframe's 0th row, column 3 and 4 and 1th row, column 2 to be set to 0

For example given another dataframe df2:

        1         2       3         4  0  0.275464  0.275404  0.2782  0.273485  1  0.275464  0.275404  0.2782  0.273485 

After applying condition, I want df2 to become:

        1         2       3         4  0  0.275464  0.275404  0.0000  0.0000  1  0.275464  0.000000  0.2782  0.273485 

Is there a good way to do this without iterating over the individual rows?


Viewing all articles
Browse latest Browse all 23247

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>