I am trying to understand threading in Python and i need to use it to translate a dataframe with 204623 rows to run much faster. I need to know how many threads i need to run and how to loop the threads by index for example for i in (I'm not sure about the parameter of the translate function) can you please check my code and correct the code for me please ? This is my code :
import threading
def trans(number,translator = Translator(),index):
df['transalted'] = df['ingredients_text'].apply(lambda x: translator.translate(x, dest='fr').text)
print ("Thread " + str(number))
thread_list = []
index=0
for i in range(1,100):
t = threading.Thread(target=trans, args=(i,index,))
thread_list.append(t)
index+=1
for thread in thread_list:
thread.start()
for thread in thread_list:
thread.join()