I have a dataframe with lots of values (just either 0 or 1). I have the table currently with just 0s and if a certain intersection (of that row and column) is true, I want to change that value to 1. For example, if my dataframe looks like this and I want to access the X element to assign a particular value to it.
ID | 1 | 2 | 3 | 4 | 5
A | | | | |
B | | | X | |
C | | | | |
The code I used is df[3][df['ID'] == 'B'] = 1
, however instead of just changing that particular value (marked X in the dataframe) to 1, it changes all the values in the column named 3.
Am I using the wrong syntax or logic here? Any answers are appreciated, thanks!