0

I have loaded 66 csv files, each containing a time series of 5000 time steps and three features with the following code:

rms = glob(sims_dir+"/rms*.csv")
df = [pd.read_csv(f).values for f in rms]
data = np.asarray(df)
data.shape
(66, 5004, 3)

Here my first axis of size 66 are my 66 unique time series. I would like to shuffle my array so that my first dimension (66) is of random order, but aren't exactly sure of the best way to do this... an alternative approach could be to load each csv randomly from its directory but I was wondering how this could be achieved in numpy.

1 Answer 1

1

Use np.random.shuffle(data). This function is dedicated for this task. See np.random.shuffle

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but does this only suffle with respect to the first dimension? i want the order of the second and third to be maintained.
Ahh "Multi-dimensional arrays are only shuffled along the first axis" thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.