Vuotelin
Vuotelin

Reputation: 47

Returning multiple dataframes with Python

So I want to write a function that looks something like this:

def return_all_tables(parameter):
    a_table = a(parameter)
    b_table = b(parameter)
    c_table = c(parameter)
    ...

Here, a, b and c are all different functions returning the dataframes a_table, b_table and c_table respectively.

What I'm not sure now is how to write the return statement to make it return the content of every dataframe.

Upvotes: 0

Views: 1456

Answers (2)

OldManSeph
OldManSeph

Reputation: 2721

You would want something like this

def return_all_tables(parameter):
    a_table = a(parameter)
    b_table = b(parameter)
    c_table = c(parameter)
    return a_table, b_table, c_table

a, b, c = return_all_tables(parameter)
display(a, b, c)

Upvotes: 1

BrokenBenchmark
BrokenBenchmark

Reputation: 19252

return a_table, b_table, c_table will return a 3-tuple containing the dataframes.

Upvotes: 0

Related Questions