I have a similar df1 with thousand columns and thousands rows. I would like to do a random sampling based on a condition in cells in row 1 (date0) Basically i would like to random sample the columns and return them and the Datetime index based on the condition if the cell on date0 row == V1 and then do the same sampling for cell==V3 and then VX..... Then I would concatenate all those samples into a singular dataframe. I want to make sure I return the original Datetime Index and not a generic Index 0,1,2,3...
abc def ghi jkl mno pqr
date0 V1 V1 V2 V3 V0 V1
date1 2 5 6 3 2 1
date2 3 1 1 3 5 6
date3 4 4 2 7 8 0
I have tried this so far but it does not work Dataset1= Dataset.ix[:,(random.sample(list(Dataset.iloc[0,:]=='V2'), SAMPLE_NUMBER))].copy()
SAMPLE_NUMBER is a random number for the number of columns to return.. thanks!
Aucun commentaire:
Enregistrer un commentaire