I have come up with a problem where my data in the column has been recorded as 90-2,91-3,90+4 etc.My motive here is to add and subtract the data directly into the column itself. Datatype of the column is an object.
df = df1["ldm"].str.split('+',expand =True)
if df.shape[1]>1:
df_2 = df[0].str.split('-',expand = True)
df_2 = df_2.fillna(value=0)
df = df.fillna(value=0)
df_2[0] = df_2[0].astype(int)
df[1] = df[1].astype(int)
df_2[1] = df_2[1].astype(int)
df_2['3'] = df[1]
df_2[0]=df_2[0]-df_2[1]
df_2[0] = df_2[0]+df_2['3']
df1['ldm'] = df_2[0]
This is my inefficient solution..I am looking for an efficient way to compute this in the dataframe.
