Skip to content
Advertisement

Dictionary of np arrays

I am working on a load function that loads files containing one pandas dataframe per file (or even better one np array). I.e. I am loading a .csv file and I want to link it to only one array variable.

This function takes as input one dictionary containing the name I want (as key) the variable to take and the name+path of the comma separated file (as value).

Here is an example of what an input of this function should look like:

JavaScript

With this function I would like to load those 4 files and return as output either the single array variables XLF, XHF, yLF, yHF or a single dictionary (or something like that) containing those variables.

I successfully loaded those files but I don’t know how to return them as outputs, given that I could have a variable number of elements in the input dict.

This is what I’ve come up to:

JavaScript

Advertisement

Answer

Don’t mess with locals() unless you’re absolutely sure you know what you’re doing.

IIUC this is what you need:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement