Python 在pandas数据框中使用parallel_apply时,如何跟踪行?

Python 在pandas数据框中使用parallel_apply时,如何跟踪行?,python,pandas,dataframe,parallel-processing,geolocation,Python,Pandas,Dataframe,Parallel Processing,Geolocation,我想使用pandas.parallel_apply而不是normal.apply在每一行数据帧上运行一个函数,以减少运行时间。是否有某种方法可以跟踪函数执行时剩余或完成的行数。以下面的函数为例 row=1 total=data.shape[0] def geocode_data(query): global row global total try: locator = geolocator.geocode(query) print(ro

我想使用pandas.parallel_apply而不是normal.apply在每一行数据帧上运行一个函数,以减少运行时间。是否有某种方法可以跟踪函数执行时剩余或完成的行数。以下面的函数为例

row=1
total=data.shape[0]

def geocode_data(query):
    global row
    global total
    try:
        locator = geolocator.geocode(query)
        print(row,' out of ', total)
        row+=1
        return((locator.latitude, locator.longitude))
    except:
        print(row, ' out of ', total)
        row+=1
        return 'Not Found'

data['Geo_coordinates']=data.parallel_apply(lambda x: geocode(x['Query']), axis=1)
这里的问题是,由于parallel_apply同时使用多个核,这意味着一次执行多行,因此在打印当前行号时,它会给出难以解释的值