python - Sequence stores according to their distances using pandas df -




i have 3 dataframes.

1.contains distances of stores main warehouse.(df1)

ware_house    store   km    1          1023    1.1    1          1056    0.3    1          1089    1.7 

2.contains distances of stores store.(df2)

start_store    destination_store     km    1023             1056             5.3    1023             1089             3.7    1056             1089             4.5    1056             1023             5.8    1089             1056             3.9    1089             1023             4.2 

i have 1 more dataframe contains test file (df3)

rowid    store    sequence  100      1023  101      1056  102      1089 

i want sequence stores in df3 such that,

first picks store minimum distance warehouse , assign sequence no. 1 in df3.

then looks combination of store stores , picks least distance store , inserts sequence no.2 in df3.

similarly checks next store same above logic.

in case df1 see store 1056 has least km.

therefore in df3, store 1056 assign sequence 1

then df2 combination of other stores store 1056 , select least distance store, in case store 1089 , assign sequence 2 in df3 . combination of store 1089 other store , generate next sequence.

my final df like:

rowid    store    sequence  100      1023      3  101      1056      1  102      1089      2 

note:this test example. have calculate many stores. help?





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

python - Minimize function with Scipy minimize -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -