Feb-05-2020, 06:51 AM
(This post was last modified: Feb-05-2020, 06:52 AM by ahmedwaqas92.)
[Update] - Set is Solved.
I realized that I just had to put * in front of each '\d' regex pattern in the below code. For anyone wanting to know the solution, below is the working code:
I realized that I just had to put * in front of each '\d' regex pattern in the below code. For anyone wanting to know the solution, below is the working code:
if "1.4.25" in df.values: if "1.4.24" in df.values: df = df.set_index("identifier") t1i4Level24 = df["1.4.24":"1.4.25"] t1i4Level24 = t1i4Level24[:-1] t1i4Level24 = t1i4Level24.reset_index(level=['identifier']) t1i4Level24 = t1i4Level24[~t1i4Level24.identifier.str.contains(fromMatch_Subjob)] countRows = t1i4Level24.identifier.count() countRows = countRows - 1 countRows = countRows.astype(float) S_t1i4Level24 = t1i4Level24['%complete'].sum() P_t1i4Level24 = S_t1i4Level24 / countRows df.at['1.4.24', '%complete']=P_t1i4Level24 df = df.reset_index(level=['identifier']) else: pass else: if "1.4.24" in df.values: df = df.set_index("identifier") loct1i4Level24 = df.loc['1.4.24':, :] loct1i4Level24 = loct1i4Level24.reset_index(level=['identifier']) tempdf = loct1i4Level24[loct1i4Level24['identifier'].str.contains(r'^\d*'+'.'+'\d*'+'.'+'\d*$')] print(tempdf)