If my was not mistaken, Pandas is single threaded in its internal operations. However, I noticed today that running a simple program as below will result as many threads as the number of CPU cores avaiable in the system being created. Why it will create these extra threads?
import threading
import pandas as pd
def use_some_cpu(row):
print(f'thread id={threading.get_ident()}')
x = 1.001
for i in range(100000):
x *= 1.001
df = pd.DataFrame(list(range(0, 10000)), columns=['foo'])
df.apply(use_some_cpu, axis=1)
If you try to run the program, you will see all the thred id values printed out are the same, which means the actual processing is done from a single thread. However, use htop command, you will see many threads are created by the program (as many as the number of cores in your system) and only one core is busy.
The test is done on Ubuntu 18.04 with pandas 1.0.2 and python 3.7.