Skip to content
Advertisement

import 2 dataframes from a function in a different python file

I have a python file which I have called Pre_Processing_File.py, this file has the function pre_Processing which loads in a text file and creates 3 data frames; userListing_DF,PrivAcc,allAccountsDF, this function then returns the 3 DFs.

What I want to do is create another script and import the 3 DFs from the pre_Processing.py file, I have created a script called call_DFs which I have also included below. The error I’m getting with this is: UnboundLocalError: local variable ‘userListing_DF’ referenced before assignment. I’m not sure where to define all 3 DFs within the script

Pre_Processing_File.py

JavaScript

call_DFs.py

JavaScript

Advertisement

Answer

JavaScript

should just be

JavaScript

since it’s returning those three variables and doesn’t require them as arguments.

Then, when calling that, just

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