python - Amend column values according to timedelta and index -
i change data in pandas dataframe.
the data collect needs assigned step value. conditions of triggers step change time or high pressure or temperature values. cannot past first step: when row on pressure (1100 psi) , under temp (40 c), "dilution" phase.
when attempting change value with:
df.ix[(df['press'] > 1100) & (df['temp'] < 40),'proc'] = 'dilute';
i seem modify top 2 rows.
items[0].head() out[37]: time mass temp press proc time 00:00:00 10:58:07 21.947102 23.306101 1.830506 dilute 00:00:01 10:58:08 22.076259 23.306101 57.274142 dilute 00:00:02 10:58:09 22.094710 23.306101 196.000203 pressurize 00:00:03 10:58:10 22.113161 23.306101 293.318991 pressurize 00:00:03 10:58:10 22.094710 23.306101 361.161415 pressurize items[0].tail() out[38]: time mass temp press proc time 00:36:12 11:34:19 18.201538 39.798763 -1.678585 pressurize 00:36:13 11:34:20 18.183087 39.719165 -1.444645 pressurize 00:36:14 11:34:21 18.183087 39.671407 -1.444645 pressurize 00:36:15 11:34:22 18.219989 39.703246 -1.444645 pressurize 00:36:16 11:34:23 18.201538 39.758964 -1.444645 pressurize
upon further inspection, indexing seem work, giving me index expect see dilution occur...
print(df.ix[(df['press'] > 1100) & (df['temp'] < 40),'proc'].head(), df.ix[(df['press'] > 1100) & (df['temp'] < 40),'proc'].tail()) time 00:00:26 pressurize 00:00:27 pressurize 00:00:28 pressurize 00:00:29 pressurize 00:00:30 pressurize name: proc, dtype: object time 00:26:08 pressurize 00:26:09 pressurize 00:26:10 pressurize 00:26:11 pressurize 00:26:12 pressurize name: proc, dtype: object
however, when applying data, first 2 values changed, , message--
futurewarning: in future, boolean array-likes handled boolean array index values[indexer] = value'
running cookbook examples give expected response.
it seems have nested index, i'm not clear on why, or how go amending this. there few layers here , searches solutions have not proved useful or provided best route clarify.
i thought reset index, , go numbers, need sort steps values , timedeltas.
the index timedelta, needed normalize number of runs launched on number of periods start runs @ same time 0 seconds. searches yield date munging , not time, hence normalizing values 0 timedelta index.
if there better way publish question, or more clarity, please ask. i'm more willing add clarity or trim. hard predict helpful info professional coder.
try
df['press'].astype('float') df['temp'].astype('float') df['proc'] = np.where((df['press'] > 1100) & (df['temp'] < 40),'dilute', "pressurized")
Comments
Post a Comment