I tried to make a code to inputting version of items. There are two dataframes, one with the items, one with the version info.
Here's a dummy data and a code I made:
import pandas as pd
from datetime import datetime
Item = pd.DataFrame({"ID":["A1","A1","A2","A2","A3","B1"],"DATE":["2021-07-05","2021-08-01","2021-02-02","2021-02-03","2021-01-01","2021-10-12"]})
Ver = pd.DataFrame({"ver_date" : ["2021-01-01","2021-07-07","2021-09-09"],"version":["1.1","1.2","1.3"]})
for id,dat in zip(Item["ID"],Item["DATE"]):
dat2 = datetime.strptime(dat,'%Y-%m-%d')
for dtc,ver in zip(Ver["ver_date"],Ver["version"]):
dtc = datetime.strptime(dtc,'%Y-%m-%d')
if dat2 >= dtc:
Item.loc[(Item.ID == id) & (Item.DATE == dat),"VER"] = ver
continue
else:
pass
So what I tried is this code. Actually this code works, but I think it is not efficient since it gives me a result in about 1~2 min. (for 200 items).