I want to do a numpy.where()
statement where if the length of the PC_list
is equal to the length of the numbers then I want the standard deviation to be calculated of the PC_list[0:number].std()
and also I want to delete the first number in PC_list
: np.setdiff1d(PC_list,PC_list[0])
. I want this process to go on until the list number is not equal to number len(PC_list[0:number]!=number
. I tried to format numpy.where()
that way however I get a syntax error when done that, so I need a correction on the numpy.where()
function below.
Code:
number = 3
list_= np.array([457.334015,424.440002,394.795990,408.903992,398.821014,402.152008,435.790985,423.204987,411.574005,
404.424988,399.519989,377.181000,375.467010,386.944000,383.614990,375.071991,359.511993,328.865997,
320.510010,330.079010,336.187012,352.940002,365.026001,361.562012,362.299011,378.549011,390.414001,
400.869995,394.773010,382.556000])
np.where(len(PC_list[0:number]==number,default = 'NA', PC_list[0:number].std(), np.setdiff1d(PC_list,PC_list[0])))
Vanilla Python Code:
from copy import deepcopy
list_ = deepcopy(PC_list)
if len(list_[0:number]==number:
STD = list_[0:number].std()
list_ = np.setdiff1d(list_,list_[0])
Error:
File "<ipython-input-93-215f70228bdc>", line 1
np.where(len(PC_list[0:number]==number,default = 'NA', PC_list[0:number].std(), np.setdiff1d(PC_list,PC_list[0])))
^
SyntaxError: positional argument follows keyword argument