lundi 16 juillet 2018

Pandas dataframe

I have a dataframe df having two columns 'voltage'(v) and 'current'(I). I want to randomly select 5 values of 'voltage' from the file, save it in 1D array like [v1,v2,v3,v4,v5], and save the corresponding values of currents in another 1D array like [I1,I2,...,I5]. Here is what I tried:

 df=pd.read_csv(file,sep=",",header=None,usecols=[0,1],names=['voltage','current'])

#pick 5 random values of voltage and save it in np array
 V= np.array( df['voltage'].sample(n=5))

How to do the same with the corresponding values of I at selected values of V?




Aucun commentaire:

Enregistrer un commentaire