How my code works is in two steps.
I have one file called filter.py which filters my dataframe according to inputs. In this file there is a function update_df() which returns data_filtered
def update_df(ToEmail, FromEmail, ToJob, FromJob, Date): FromEmailF = (data['fromEmail'] == FromEmail) ToEmailF = (data['toEmail'] == ToEmail) FromJobF = (data['fromJob'] == FromJob) ToJobF = (data['toJob'] == ToJob) DateF = (data['date'] == Date) Filter = (FromEmailF & ToEmailF & FromJobF & ToJobF & DateF) data_filtered = data[Filter] return data_filtered
In another file, I need to access this data_filtered.
I first imported update_df but I can’t figure out how I can take data_filtered from the function.
I tried the following
def datafilter(data_filtered): df = data_filtered return df
but now I can’t access df either no matter what I do. I just need a way to get the dateframe itself. I hope any of you guys can help me and I can provide more info if needed.
Source: Python Questions