2

I have a question related to the saving an array(.npy).

I have a computation that produces a new array for every loop. Once a while (let's say every 10 steps) I would like to save my output into .npy with a specific name, let's say result_at_step_10.npy. Of course at steps 20, the file name should be result_at_step_20.npy how could I do that in python?

2
  • I would recommend you using a library called pandas. It's easy to use and does pretty much everything you can think of :) Commented Mar 20, 2020 at 7:36
  • Could you please elaborate? Commented Mar 23, 2020 at 4:42

1 Answer 1

2

If renaming the file is what your are looking for, here is the code

import os
os.rename("old_name","new_name")
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, thank you for your answer. Unfortunately, that is not what I need it. Instead of renaming the array, what I want is saving it with another name. Maybe this an example what I want for i in range (0,100): a = i+1 (and here is the code that I do not know) save (a) = a_at_i.npy

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.