I have a column TS
which is varying from -60 to 60 and I have a column V
which is from -0.1 to 0 to 1 and repeating again and again.
I want to add 15 to those values of TS
when variable V<0
, subtract 15 when V>0
. Values in TS
and V
are of format float64. There are some nan
values in TS
as well so those can be replaced by zeros what I did here. I tried this but afterward I don't know what to do further.
data = pd.read_table(filename,skiprows=104,decimal=',', sep=';',header=None,names=["V ","TS "])
``
import numpy as np
TS = data[data.keys()[9]]
TS = np.array(TS)
np.nan_to_num(TS)
TS4 = TS[V<0]+15
TS5 = TS[V>0]-15
TS6 = TS[V==0]
TS7 = TS[np.isnan(TS)] = 0
where
+-------+--------------------+--------------------+------------+
| Index | TS (kPa) | NS(kPa) | V (mm/min) |
+-------+--------------------+--------------------+------------+
| 0 | 36.052101 | 97.384283 | -0.1 |
| 1 | 20.240409 | 102.012401 | -0.1 |
| 2 | 10.491882 | 97.26910600000001 | -0.1 |
| 3 | 8.717836 | 101.145252 | -0.1 |
| 4 | 3.7307309999999996 | 99.038843 | -0.1 |
| 5 | 3.585318 | 99.413168 | 0.1 |
| 6 | 3.6144 | 100.562722 | 0.1 |
| 7 | 2.676773 | 100.13413100000001 | 0.1 |
| 8 | -4.776546 | 97.868247 | 0.1 |
+-------+--------------------+--------------------+------------+
Expected output
+-------+--------------------+--------------------+------------+
| Index | TS (kPa) | NS(kPa) | V (mm/min) |
+-------+--------------------+--------------------+------------+
| 0 | 51.052101 | 97.384283 | -0.1 |
| 1 | 35.240409 | 102.012401 | -0.1 |
| 2 | 25.491882 | 97.26910600000001 | -0.1 |
| 3 | 23.717836 | 101.145252 | -0.1 |
| 4 | 18.7307309999999996 | 99.038843 | -0.1 |
| 5 | -12.585318 | 99.413168 | 0.1 |
| 6 | -12.6144 | 100.562722 | 0.1 |
| 7 | -14.676773 | 100.13413100000001 | 0.1 |
| 8 | -19.776546 | 97.868247 | 0.1 |
+-------+--------------------+--------------------+------------+