问题
df=pd.DataFrame({'0':["abc-dsa","abc-xyz","abt-cab","xyz-0vc"],'1':['axc-0aa',"abd-xyz","abt-Rac","xyz-1avc"],'3':['bcd-aaa',"NaN","bcd-9ac","xyy-9vc"]})
I have this Data Frame, I want to push it into excel and run a macro.
First condition is IF first three characters are same in row then they will be stored in single column
second condition is IF they the first three characters are not same they will be saved in same row.
chain of operation is.
read data frame
check conditions and store data accordingly for first row
run a macro and wait for 1 min
read data frame (second row in dataframe).check conditions and store it again in excel run macro
EXAMPLE:
first row in dataframe has abc-dsa, abc-xyz, abt-cab, xyz-0vc.
In this we have two sets of data that are identical for first three characters i.e. abc so these will be stored in column A1 in excel rest do not match and hence will be stored in B1 and C1 respectively.
in excel
A1
abc-dsa
abc-xyz
B1
abt-cab
c1
xyz-0vc
I just want to know if it is possible to check each row values and store it in excel or not.
来源:https://stackoverflow.com/questions/61450810/how-to-check-conditions-in-each-row-in-data-frame-and-push-the-data-accordinly-i