0

I have a data frame like below:

0       INT_ID  F1_ID  chr  start   T1    T2
1  F143-F44837    143    1   5000   True  True
2    F144-F153    144    1  15000   True  True
3    F152-F153    152    1  20000   True  True
4    F152-F175    152    2  25000   True  True
5    F152-F175    152    3  40000   True  True

and I want to change a particular cell. for example :

if F1_ID==144 and start==15000 then T1 should be False.

how can I change a cell in data frame pandas in python?

neda
  • 13
  • 3

1 Answers1

1

Use loc and your conditions. It is important to use loc to avoid SettingWithCopyWarning.

df.loc[df['F1_ID'].eq(144) & df['start'].eq( 15000), 'T1'] = False

output:

   0       INT_ID  F1_ID  chr  start     T1    T2
0  1  F143-F44837    143    1   5000   True  True
1  2    F144-F153    144    1  15000  False  True
2  3    F152-F153    152    1  20000   True  True
3  4    F152-F175    152    2  25000   True  True
4  5    F152-F175    152    3  40000   True  True
mozway
  • 194,879
  • 13
  • 39
  • 75