I have the following code. What i am trying to do is to run many instances of function. In this case for example, the function bigbangtheory()
would return df. Could you please advise how can i save the output of the function if i run this code in multithread
.
import threading
import numpy as np
import pandas as pd
def bigbangtheory():
new = {'name': ['Sheldon', 'Penny', 'Amy', 'Bernadette', 'Raj', 'Howard '],
'episodes': [31, 24, 31, 29, 37, 40],
'gender': ['male', 'female', 'female', 'female', 'male', 'male']}
a = pd.DataFrame(new, columns = ['name','episodes', 'gender'])
return a
def bigbangtheory1():
old = {'name': ['Sheldon', 'Penny', 'Amy', 'Bernadette', 'Raj', 'Howard'],
'episodes': [12, 32, 31, 32, 37, 40],
'gender': ['male', 'female', 'female', 'female', 'male', 'male']}
b = pd.DataFrame(new, columns = ['name','episodes', 'gender'])
return b
if __name__ == "__main__":
# creating thread
t1 = threading.Thread(target=bigbangtheory)
t2 = threading.Thread(target=bigbangtheory1)
t1.start()
t2.start()
t1.join()
t2.join()